Google Sheets: Formula in an Array in a Formula - google-sheets

I'm trying to find a way to consolidate formulas into 1 cell. As of right now i have 2 mildly complicated formulas using up multiple columns.
I'm trying to put the formulas as an array in a single cell.
To avoid confusing the matter, i've only included a simplified version of the formulas and only using 1 column.
Edit:
Here is the Spreadsheet in question, the Better Mobs sheet
Ok, so i tried to implement the solution and it didn't work the way i needed. Before i consolidate and just use 1 spreadsheet, the full formula in cell F1 is:
=match(max(F2:F),F2:F,0)+1&" - "&INDIRECT("A"&match(max(F2:F),F2:F,0)+1)
and cell F2 is:
=IFERROR(E269/ROUNDUP($C269/MAX(0,importrange("1rkS5zujl6oo66JNbhb8yWOjgOqRoXhvyGa-nr95krJ4","Damage Reward!$B$26")/2-$K269)*MAX((MIN(100+sqrt(importrange("1rkS5zujl6oo66JNbhb8yWOjgOqRoXhvyGa-nr95krJ4","Damage Reward!$B$27"))-sqrt(O269)-MAX($B269-importrange("1rkS5zujl6oo66JNbhb8yWOjgOqRoXhvyGa-nr95krJ4","Damage Reward!$B$3"),0)*5,100)/100),0)*2),"")

Does this formula work as you want in cell C1:
={MAX(ArrayFormula(IFERROR(B2:B*D2:D/E2:E)));ArrayFormula(IFERROR(B2:B*D2:D/E2:E))}

Related

Google Sheet SUMIF across range of cells

I am trying to use a formula in google sheets to find averages based on the contents of a different cell.
Below is some sample data, I am pretty sure I have done similar in the past in Excel by using table headers as a reference but struggling to see how to achieve this in google sheets.
Columns B, C, D to be calculated, currently this is the formula used for D3 (same sort of thing for D4) =IFERROR(ROUND(SUM(E3:H3)/COUNT(E3:H3),2),0)
Just needing to work out the formula for the cells with red text, any help would be appreciated.
as an example C3 would be the average for any numbers in row 3 where it has DeviceB e.g. (2+10+6)/3
Try
=AVERAGEIF($E$2:$H$2,B$1,$E3:$H3)
AVERAGEIF

how can I write a formula that uses a cell's contents when building a range reference to the name of another sheet?

I have a large Google Sheets spreadsheet that has individual sheets for financial statements of activity for multiple years. I want to reference particular columns of those in other sheets, and I've successfully figured out how to do that with an HLOOKUP function. However, because I want to do this for multiple years, I'd like that HLOOKUP function to pick up the name of the sheet to reference from its column header. Right now, I'm hard-coding it like this—you can see the HLOOKUP range refers to cells in the "2021 Overall" sheet. The hard-coded approach works but makes adding a new year tedious. Ideally, the HLOOKUP formula would read the contents of its column header cell to determine which year it is.
As best I can tell, the solution is to use INDIRECT, but I can't figure out any way to build the formulate with INDIRECT and not get an error. For instance, this seemed like it should work. As you can see, I have 2021 in cell D4, and my INDIRECT statement is referencing that and building the rest of the range.
I've also tried using INDIRECT with an explicit CONCATENATE, with no more success.
Any ideas for how to look up that D4 cell and slide it into the HLOOKUP range?
Thank you!
Try to remove the "'"& before D4 and the ' after the Overall.
Your formula should look like this:
=IFERROR(HLOOKUP($A$2,INDIRECT(F4 &" Overall!$A$5:$X$150", Utility!$A10, FALSE)))
With Nikko's nudges in the right direction, I eventually figured out the right format. This allows the formula to work in multiple sheets and to be filled right (for more years) and down (for more classes).
=IFERROR(HLOOKUP($A$2,INDIRECT("'"D$4&" Overall'!$A$5:$X$150"), Utility!$A3, FALSE))
Note that if you try to replicate this, you may need to type the formula out from scratch—I had a problem where pasting it in didn't work. Once I'd retyped it and Google Sheets acknowledged it, it worked from then on in the spreadsheet, even when pasted from sheet to sheet.

Google Sheets, Is it possible to use Arrayformula to expand formulas downward when the formula uses arrays

I've been using Arrayformula to auto-expand formulas (such as "=Left(A2:A,B2:B-1") downward, but I need some help understanding this formula. I've read up on the function itself and browsed many forums about this but I can only find articles explaining how to use this with simple formulas, so I'm going to try to as this as simply as possible here: Is it possible to use Arrayformula to expand formulas downward when the formula uses arrays?
The summary for Arrayformula reads "Enables the display of values returned from an array formula into multiple rows and/or columns and the use of non-array functions with arrays." This was my understanding of how Arrayformula populated a formula into rows automatically. Using this I thought of it as writing a formula that generated an array of formulas, and then splitting them up with Arrayformula. This seems to not work with some formulas such as concatenate, which I will focus my question on. This example is far from my real life problem, but if someone could show me a solution I can apply it elsewhere.
Arrayformula spreadsheet example
Usually when I use Arrayformula with A1:A it would expand the formula through the column, referencing the corresponding rows as it went. With this example I want to have Column C be the concatenated result of columns A and B. Is this possible with Arrayformula? This question is not specific to concatenate, that is just the simplest one that came to mind. Another example would be Countif. Lets say I want to see how many values in the first 5 columns are over 20, and I want that formula to auto populate down, is that possible and if so how would it be done?
Arrayformula second example
P.S. Please don't say copy the formula using the drag handle in the lower right.

Using IMPORTRANGE, INDIRECT, and CONCATENATE together

I have a sheet that pulls numbers from several different sheets to amalgamate numbers. Each week, a new sheet is added to the source files, all with the same name. I'd like to update the amalgamated sheet by changing one cell instead of many.
When the tab is located in the same Google sheet, this is easily done with INDIRECT.
Right now, the formula in the amalgamated sheet is:
=IMPORTRANGE(M4, "Aug29!$F$2")
That formula is on each line to pull from several different sheets:
=IMPORTRANGE(M5, "Aug29!$F$2")
=IMPORTRANGE(M6, "Aug29!$F$2")
and so on.
Each week, the "Aug29" changes to the new date - "Sep5", "Sep12", etc.
What I'd like to do is use INDIRECT to pull that part of the equation in (from cell Z1) so that I don't have to update each formula.
I was thinking I could use CONCATENATE to create the "Aug29!$F$2" portion of the formula with INDIRECT:
=IMPORTRANGE(M4, CONCATENATE(INDIRECT(Z1), "!$F$2"))
The problem is, the IMPORTRANGE formula requires quotations around the range string, and I can't figure out how to add them.
Weird problem, I'm sure, but wondering if there's anyone with a solution?
Short answer
Use =IMPORTRANGE(M4, CONCATENATE(Z1, "!$F$2")) or =IMPORTRANGE(M4, Z1&"!$F$2")
Explanation
INDIRECT requires a string that represents a cell or range references, like "Z1" but it will increase unnecessarily the complexity of your formula.
If Z1 has the name of the sheet, then just concatenate it by using CONCATENATE, CONCAT or &
UNTESTED. Please try something like:
=IMPORTRANGE(M4,Z$2)
with in Z2 something like:
=Z1&"!$F$2"
In other words, I think your IMPORTRANGE does not like INDIRECT.

Google spreadsheets, arrayformula queries

I have two questions.
Question #1:
I am using this formula =SUM(E2,F2,G2,H2) for D2 cell.
Where E2, F2, G2, H2 are numbers
I want to repeat this formula for the whole D column. Please help me how to do this.
I see there is ArrayFormula, but I am confused how to use it, since I am not getting any results if I use
For e.g.
I tried,
=arrayformula(E2:E+F2:F+G2:G+H2:H)
But the answer is coming wrong.
Question #2:
I am using this formula =CONCATENATE(N2,O2,T2,U2,AJ2,AK2,BF2,BG2,CH2,CI2) for J2 cell.
Where N2,O2,T2.. all are strings
I want to repeat the same formula to whole cells in J3, J4 etc. automatically when the user enters the data.
I don't even know how to try this. Please help me by proving your answers.
Your first formula seems to work correctly, although if you want to hide zeroes on blank rows then try this formula in cell D2:
=ArrayFormula(IF(E2:E+F2:F+G2:G+H2:H=0,"",E2:E+F2:F+G2:G+H2:H))
To concatenate within an arrayformula, try using the & sign:
=ArrayFormula(N2:N&O2:O&T2:T&U2:U&AJ2:AJ&AK2:AK&BF2:BF&BG2:BG&CH2:CH&CI2:CI)

Resources