I have a formula in cells F1 and G1 of this sheet. I want to keep the text that is in cells F/G8 and F9&G9 however it's giving me an error. Note that the formula is in an array so that it can apply retroactively to all of the cells in the column.
Here is the code used in Cell F1:
=ARRAYFORMULA(IFNA(VLOOKUP(B2:B, QUERY('Raw Logs'!C2:F, "select C,sum(F) group by C label sum(F)''"), 4, 0)))
Here is the code used in Cell G1:
=ARRAYFORMULA(IFNA(VLOOKUP(B2:B, QUERY('Raw Logs'!C2:H, "select C,sum(H) group by C label sum(H)''"), 6, 0)))
Additionally, the data from the formula in Cell C1 is no longer populating (it was before) - the error says it can't because it's unable to overwrite C9 however there was text in C9 earlier and the data from the formula was still populating.
Here's the formula used in Cell C1:
=ArrayFormula(IFERROR(VLOOKUP(B:B,'Roster Registrations'!F1:G,2,FALSE)))
Any tips on how I can resolve this?
array formula needs a space to roll out - that's why. if you want to run it from that 1st row delete cells F8:F9 and use:
={"";"";"";"";"";"";"";"Total for February";
"Activity"&CHAR(10)&"Hours"; "";
ARRAYFORMULA(IFNA(VLOOKUP(B11:B&"", TEXT(QUERY('Raw Logs'!C2:F*1,
"select Col1,sum(Col4)
where Col1 is not null
group by Col1
label sum(Col4)''"), {"#", "[h]:mm:ss"}), 2, 0)))}
for G1 fx delete G9 and use this in G1:
={"";"";"";"";"";"";"";"";
"Number of"&CHAR(10)&"Tests"; "";
ARRAYFORMULA(IFNA(VLOOKUP(B11:B, QUERY('Raw Logs'!C2:H*1,
"select Col1,sum(Col6)
where Col1 is not null
and Col1 <> 0
group by Col1
label sum(Col6)''"), 2, 0)))}
Related
Say I had a list like this.
Group 1 Group 2
Edward, C Kate, A
Mark, F Ava, Z
Now, in a different column =IF(COUNTIF('Gender'!$A$2:$B$3, "Kate, A"), "", "") is my current formula. I would like to make the first set of empty speech marks return Group 1 or Group 2 depending what column it is. I still require the COUNTIF because my actual sheet has values which will not be contained in either column.
Thanks.
try:
=INDEX(IFNA(VLOOKUP("Kate, A", SPLIT(FLATTEN(
IF(Gender!A2:B="",,Gender!A2:B&"×"&Gender!A1:B1)), "×"), 2, 0)))
update:
=INDEX(IFNA(VLOOKUP(A1:A, QUERY(SPLIT(FLATTEN(
IF(Groups!B2:C="",,Groups!B2:C&"×"&Groups!A1&"×"&Groups!B1:C1),
IF(Groups!F2:G="",,Groups!F2:G&"×"&Groups!E1&"×"&Groups!F1:G1)), "×"),
"select Col1,max(Col3) where Col2 is not null
group by Col1 pivot Col2 label Col1'"&A1&"'"), {2, 3}, 0)))
demo sheet
I have a Google Sheets question, which I have not been able to figure out yet with Google-Fu and RTFM:
Take the following spreadsheet as an example:
https://docs.google.com/spreadsheets/d/1IvMVaUdUDfYOoKyG0Uwd2n0M1mLjOTE5yZQ9K2R3q2M/edit?usp=sharing
In case the sheet gets lost in time, I am going to post its contents here:
Sheet1:
foo
withdrawal
deposit
C
4
10
D
10
E
10
4
As you see here, the withdrawal field for the D value being foo is empty, i.e. null
Sheet2:
foo
balance
C
=INDEX(QUERY({Sheet1!$A$2:C}, "SELECT SUM(Col3) - SUM(Col2) WHERE Col1 = '"&A2&"'"), 2)
D
=INDEX(QUERY({Sheet1!$A$2:C}, "SELECT SUM(Col3) - SUM(Col2) WHERE Col1 = '"&A3&"'"), 2)
E
=INDEX(QUERY({Sheet1!$A$2:C}, "SELECT SUM(Col3) - SUM(Col2) WHERE Col1 = '"&A4&"'"), 2)
The result is
foo
balance
C
6
D
E
-6
As you see, the balance field for the category D is null, although it should be -10.
The fix for that is to put a 0 into the deposit field in Sheet1 explicitly.
In my example, I get that data using a csv-export, and fields are generally empty and not 0, and it is cumbersome to add the 0 there. Is there a way to have something like COALESCE in that sum there (like in SQL)?
Please let me know.
it seems like something quite a bit simpler would avoid the problem:
=SUMPRODUCT(Sheet1!C:C-Sheet1!B:B,Sheet1!A:A=A2)
for cell B2.
Why don't you just add this in cell A1 of Sheet2 instead of all the Query:
=arrayformula({Sheet1!A1,"balance";if(Sheet1!A2:A<>"",{Sheet1!A2:A,Sheet1!C2:C-Sheet1!B2:B},)})
Obviously ensure cells Sheet2!A2:A and Sheet2!B1:B are empty.
If you have duplicate values of foo, try:
=arrayformula(query({Sheet1!A1,"balance";if(Sheet1!A2:A<>"",{Sheet1!A2:A,Sheet1!C2:C-Sheet1!B2:B},)},"select Col1,sum(Col2) where Col1 is not null group by Col1 label sum(Col2) 'balance'",1))
A better option for a single-cell formula, referencing multiple sheets would be:
=arrayformula(query(
{Sheet1!A:A,n(Sheet1!B:C);Sheet2!A2:A,n(Sheet2!B2:C);Sheet3!A2:A,n(Sheet3!B2:C)},
"select Col1,sum(Col3)-sum(Col2) where Col1 is not null group by Col1 label sum(Col3)-sum(Col2) 'balance' ",1))
I have the following sheet:
https://docs.google.com/spreadsheets/d/1GcC47i7193Hjt0QbTQ5OT_2SZQjPO_4wKmKKMwy_hQE/edit?usp=sharing
I need to get the date (from row 1) for each of the products (col a) corresponding with the col one after the last value in each row.
EG
For product A it would be 1/2/2021
For product B it would be 1/3/2021
To raise the limitation of the VLOOKUP formula by JPV,
Assuming there's only one "D" per row
you can use the following for any number of x's in any number of rows
={"Product","Date";
QUERY(INDEX(SPLIT(FLATTEN(IF(B2:D6="x", A2:A6&"_"&B1:D1,)),"_")),
"select Col1, max(Col2) where Col2 is not null
group by Col1 label max(Col2) '' ",0)}
Assuming there's only one "D" per row, in B8 try
=filter($B$1:$D$1, filter($B$1:$D$6, $A$1:$A$6=$A8)="D")
and fill down.
For a single formula (array output) try in B8
=INDEX(VLOOKUP(A8:A12, SPLIT(FLATTEN(IF(B2:D6="D", A2:A6&"_"&B1:D1,)), "_"), 2, 0))
See if that helps?
Here is a problem to solve with a Google Sheets formula.
I have a big table (sheet “data” with headers on the first row) with those columns:
A, product reference
B: customer
C to F, KPI1 to KPI4
On another sheet, a grid of product references (A2:A) by customer (B1:1).
Now I need to fill each cell from the grid with the concatenation of KPIs (data!C24&"|"&data!D24&"|"&data!E24&"|"&data!F24)
Could you workout a single formula to fill all the cells?
Here is a sample spreadsheet with the data and grid sheet:
https://docs.google.com/spreadsheets/d/1iA_kw4kKw99Qk69X4tST9U-QN2SeG2EN3KEeyG6AtHs/edit?usp=sharing
I have worked out a formula which does the job, though with very poor performance on large dataset:
=ARRAYFORMULA(
IFNA(
VLOOKUP(
$B3:$B&"|"&C$2:$2,
ARRAYFORMULA(
{data!A2:A&"|"&data!B2:B,data!C2:C&"|"&data!D2:D&"|"&data!E2:E&"|"&data!F2:F}
),2,0
),""
)
)
Solution
Use an ArrayFormula on a Query with Pivot:
=ARRAYFORMULA(
QUERY(
{data!A2:A, data!B2:B, data!C2:C&"|"&data!D2:D&"|"&data!E2:E&"|"&data!F2:F},
"select Col1,max(Col3) where Col1 is not null group by Col1 pivot Col2",0
)
)
a shorter version of previous answer (no need for pre-sorting coz pivot will sort it on its own):
=ARRAYFORMULA(QUERY(
{data!A2:A, data!B2:B, data!C2:C&"|"&data!D2:D&"|"&data!E2:E&"|"&data!F2:F},
"select Col1,max(Col3) where Col1 is not null group by Col1 pivot Col2", 0))
Try this on the first cell of your grid:
=ArrayFormula(query(sort({data!A:A,data!B:B,transpose(substitute(query(transpose(data!C:F),,4)," ","|"))},1,true,2,true),"select Col1, max(Col3) where Col1 is not null group by Col1 pivot Col2",0))
I have a SUMIFS formula that works fine, but I have to drag it down to populate every column, which is quite impractical for the amount of data I have in my spreadsheet, therefore I want to turn it into an ARRAYFORMULA. The formula is supposed to calculate how many of a product was purchased in a month. It currently looks like this:
=SUMIFS(All!$N$3:$N, All!$AG$3:$AG, ">=1/1/2018", All!$AG$3:$AG, "<=31/1/2018", All!$L$3:$L, $A2)
All!N contains the quantity of an item the customer purchased, All!AG contains the date, and All!L contains the product code which is checked against the product code in column A.
I tried simply doing
=ARRAYFORMULA(SUMIFS(All!$N$3:$N, All!$AG$3:$AG, ">=1/1/2018", All!$AG$3:$AG, "<=31/1/2018", All!$L$3:$L, $A$2:$A))
but that only works for cell A2 - it just prints the same result as the other formula and doesn't carry on down the column, which is what I want it to do. That solution worked with a SUMIF formula I have (it does the same thing but doesn't check the date) but it won't work with SUMIFS. I'm not sure why and I'm not the best at troubleshooting these spreadsheet formulas so I'm hoping someone can help.
Update: Here is a dummy sheet showing the issue: https://docs.google.com/spreadsheets/d/1pX-icbJxmy8A0jhKLnSRxhZTLRgYFG_iU2BOQrseCCg/edit?usp=sharing
paste in B2 cell:
=ARRAYFORMULA(IF(LEN($A$2:$A), IFERROR(VLOOKUP($A$2:$A,
QUERY({All!$B$3:$D},
"select Col1, sum(Col2)
where Col3 is not null
group by Col1
label sum(Col2)''", 0), 2, 0), 0), ))
paste in C2 cell and drag to the right:
=ARRAYFORMULA(IF(LEN($A$2:$A), IFERROR(VLOOKUP($A$2:$A,
QUERY({All!$B$3:$D},
"select Col1, sum(Col2)
where Col3 >= date '"&TEXT( C$1, "yyyy-mm-dd")&"'
and Col3 <= date '"&TEXT(EOMONTH(C$1, 0), "yyyy-mm-dd")&"'
group by Col1
label sum(Col2)''", 0), 2, 0), 0), ))
spreadsheet demo