I currently have a database that looks like this:
But I would like for the output of the database to look like this:
I have tried using INDEX MATCH but I haven't been able to find a way to exclude blank values from the output.
A formula I have used but have not exactly returned the expected output is:
=INDEX('Input sheet'!B2:I7,0,MATCH(A2,'Input sheet'!A2:A7,0))
Is there a formula that can return non-blank values in a row, as shown on the output sheet?
https://docs.google.com/spreadsheets/d/1HdkBPhzB5oZ0RyKZzAOkPIXT81upgHiGBLfgXsrOZDI/edit?usp=sharing
=ARRAYFORMULA({UNIQUE(FILTER('Input sheet'!A2:A, 'Input sheet'!A2:A<>"")), TRIM(SPLIT(
TRANSPOSE(QUERY(IF(QUERY(QUERY(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRIM(TRANSPOSE(QUERY(
TRANSPOSE(IF(LEN('Input sheet'!B2:J), "♠"&'Input sheet'!A2:A&"♦"&'Input sheet'!B1:J1, ))
,,999^99))),,999^99), "♠")), "♦")),
"select count(Col2) where Col2 is not null group by Col2 pivot Col1",0), "offset 1",0)<>"",
QUERY(QUERY(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRIM(TRANSPOSE(QUERY(
TRANSPOSE(IF(LEN('Input sheet'!B2:J), "♠"&'Input sheet'!A2:A&"♦"&'Input sheet'!B1:J1, ))
,,999^99))),,999^99), "♠")), "♦")),
"select Col2,count(Col2) where Col2 is not null group by Col2 pivot Col1", 0),
"select Col1 offset 1", 0)&"♥", ),,999^99)), "♥"))})
REVERSE OF ABOVE:
=ARRAYFORMULA(TRANSPOSE(QUERY(SPLIT(TRANSPOSE(SPLIT(TRIM(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(LEN('Output sheet'!B2:F), "♠"&'Output sheet'!A2:A&"♦"&'Output sheet'!B2:F, ))
,,999^99)),,999^99)), "♠")), "♦"),
"select Col2,count(Col2) where Col2 is not null group by Col2 pivot Col1", 0)))
Related
I have a spreadsheet where users fill out a form, they have multiple options they can pick by clicking the checkboxes.
The responses sheets looks like this
I want to filter the results by option, so my main goal is to get the total amount of options selected:
I've been trying with COUNTIF but it's not working because I'm not selecting the specific response
=COUNTIF('Form Responses 1'!C2:F4,"*"&$B$1&"*")
I'm assuming I need to add a VLOOKUP but I'm not sure how to match it with the option
Here's a spreadsheet to play around with it
try:
=INDEX({QUERY(TRIM(SPLIT(FLATTEN(A2:A&"×"&SPLIT(B2:B, ",")), "×")),
"select Col1,count(Col1) where Col2 is not null group by Col1 pivot Col2 label Col1 'Person'");
{"Total", TRANSPOSE(MMULT(TRANSPOSE(QUERY(QUERY(TRIM(SPLIT(FLATTEN(A2:A&"×"&SPLIT(B2:B, ",")), "×")),
"select count(Col1) where Col2 is not null group by Col1 pivot Col2"), "offset 1", )*1),
SEQUENCE(COUNTUNIQUE(TRIM(FLATTEN(SPLIT(TEXTJOIN(",", 1, B2:B), ",")))), 1, 1, )))}})
Perhaps a formula like this:
=IFNA(QUERY({$A$2:$A$6, $B$2:$B$6}, "Select 1 where Col2 contains '"&B$9&"' and Col1 = '"&$A10&"' order by Col1 label 1 ''"), 0)
This outputs a 1 if the referenced cell contains the specified text, and a 0 otherwise. See the docs for the Query Function and the Query Language for more information.
I have data that looks like this:
And I want it to look like this:
Formula ideas?
Thanks!
Maria
try:
=ARRAYFORMULA(TRIM(SPLIT(FLATTEN(QUERY(TRANSPOSE(QUERY(QUERY({A2:A&"×"&B2:B,
TRIM(FLATTEN(QUERY(TRANSPOSE({"×"&C2:D}),,9^9))),
TRIM(FLATTEN(QUERY(TRANSPOSE(C2:D),,9^9)))},
"select Col1, max(Col2) where Col3 is not null group by Col1 pivot Col3"),
"offset 1", 0)),, 9^9)), "×")))
So I have a timesheet for a project I'm working on, and I'd like to see how many hours I've worked by week.
I found an answer from this post: Create Weekly/Monthly/Yearly line chart in Google Sheets to sum amounts within same week/month/year range which got me really far.
Monthly and Yearly queries are working great thanks to user player0. However, weekly sorting is borked for me. The code I'm using now comes from that post:
=ARRAY_CONSTRAIN(ARRAYFORMULA(
IF(J2="Weekly", QUERY({"week "&WEEKNUM(A2:A)&" "&YEAR(A2:A), E2:E, YEAR(A2:A)+WEEKNUM(A2:A)*0.083},
"select Col1,sum(Col2),Col3 where Col2 is not null group by Col1,Col3 order by Col3 label sum(Col2)''", 0),
IF(J2="Monthly", QUERY({TEXT(A2:A, "mmmm")&" "&YEAR(A2:A), E2:E, YEAR(A2:A)+MONTH(A2:A)*0.083},
"select Col1,sum(Col2),Col3 where Col2 is not null group by Col1,Col3 order by Col3 label sum(Col2)''", 0),
IF(J2="Yearly", QUERY({YEAR(A2:A), E2:E},
"select Col1,sum(Col2) where Col2 is not null group by Col1 label sum(Col2)''", 0), )))), 999^99, 2)
Here's what the sheet looks like
I know very little about Google Sheets, so you'll have to keep it simple for me XD
try:
=ARRAY_CONSTRAIN(ARRAYFORMULA(
IF(J2="Weekly", QUERY(QUERY({"week "&WEEKNUM(A2:A)&" "&YEAR(A2:A), E2:E, "w"&YEAR(A2:A)&TEXT(WEEKNUM(A2:A), "00")},
"select Col1,sum(Col2),Col3 where Col2 is not null group by Col1,Col3 order by Col3 label sum(Col2)''", 0), "offset 1", 0),
IF(J2="Monthly", QUERY({TEXT(A2:A, "mmmm")&" "&YEAR(A2:A), E2:E, YEAR(A2:A)+MONTH(A2:A)*0.083},
"select Col1,sum(Col2),Col3 where Col2 is not null group by Col1,Col3 order by Col3 label sum(Col2)''", 0),
IF(J2="Yearly", QUERY({YEAR(A2:A), E2:E},
"select Col1,sum(Col2) where Col2 is not null group by Col1 label sum(Col2)''", 0), )))), 999^99, 2)
Is there any way in Google Sheets to automatically change cells from the current format to intended format like in this screenshot:
=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(TRANSPOSE(SPLIT(
CONCATENATE(TRANSPOSE(QUERY({"♦"&A1:A&"♠", B1:B&", "},
"select max(Col2) where Col2 is not null group by Col2 pivot Col1", 0))),
"♦")), "♠")), ",$", ))
I have a range of data which I need to filter by non-empty cells within a specific sub-range, while generating a new row for each non-empty cell within that sub-range.
Observe the following example sheet, containing input data and desired output:
https://docs.google.com/spreadsheets/d/1c1lOtXpGbY9MwYHEoFIe1fxgW7TnygcgImCIIp2gzqM/edit?usp=sharing
For each "Type 1 - 4" cell that is not blank, a new row should be output containing the date, name, type and value from the input row.
What formula or functions are needed in order to accomplish this?
I am not new to using QUERY, VLOOKUP, and FILTER, and yet am unable to achieve the desired output via formula, nor even come up with anything that begins to get close.
=ARRAYFORMULA({"Date", "Name", "Type", "Value"; QUERY({
QUERY({B3:I, IF(F3:F<>"", $F$2, )},
"select Col1, Col2, Col9, Col5 where Col9 is not null", 0);
QUERY({B3:I, IF(G3:G<>"", $G$2, )},
"select Col1, Col2, Col9, Col6 where Col9 is not null", 0);
QUERY({B3:I, IF(H3:H<>"", $H$2, )},
"select Col1, Col2, Col9, Col7 where Col9 is not null", 0);
QUERY({B3:I, IF(I3:I<>"", $I$2, )},
"select Col1, Col2, Col9, Col8 where Col9 is not null", 0)},
"select * order by Col1 asc", 0)})
An alternative answer, similar to player0's in concept, but a bit simpler. It selects columns after the full array of ranges has been formed:
=arrayformula(
query(
{
B2:B, C2:C, iferror(F2:F/0, F2), F2:F;
B2:B, C2:C, iferror(G2:G/0, G2), G2:G;
B2:B, C2:C, iferror(H2:H/0, H2), H2:H;
B2:B, C2:C, iferror(I2:I/0, I2), I2:I
},
"where Col4 is not null
order by Col1",
0
)
)
Via Google Product Forum.