Trim rows and tranpose in Google Sheets - google-sheets

I'm trying to trim this rows horizontaly and then transpose the values in two columns with this formula:
=FILTER(7:8, TRIM(FLATTEN(QUERY(TRANSPOSE(7:8),,9^9)))<>"") But it looks like it don't do anything. Here is the data:
Help with this please

The following formula should produce the behaviour you want:
=QUERY(TRANSPOSE(7:8),"select * where Col1 is not null")

Can try FILTER() function.
=TRANSPOSE(FILTER(A7:I8,A7:I7<>""))
Also could use QUERY() like-
=QUERY(TRANSPOSE(A7:J8),"where Col1 is not null",0)

Related

Google Sheets: How can I Flatten and Split Data while including multiple columns?

I would like to pull data from Google Sheets form responses that include checkboxes. The checkboxes are output into single column cells by commas.
Data/Form Responses sheet:
enter image description here
Current and Expected Results
enter image description here
Current Formula
=ARRAYFORMULA(TRIM(QUERY(SPLIT(FLATTEN(IF(IFERROR(SPLIT('Form Responses'!E2:E, ","))="",,
'Form Responses'!B2:B&"×"&SPLIT('Form Responses'!E2:E, ","))), "×"),
"where Col2 is not null")))
If anyone could please help I would appreciate it!
SUGGESTION
Perhaps you can try this tweaked formula:
=ARRAYFORMULA(TRIM(QUERY(SPLIT(FLATTEN(IF(IFERROR(SPLIT('Form Responses'!E2:E, ","))="",,TEXT('Form Responses'!A2:A,"MM/DD/YYYY HH:MM:SS")&"×"&'Form Responses'!B2:B&"×"&'Form Responses'!C2:C&"×"&'Form Responses'!D2:D&"×"&SPLIT('Form Responses'!E2:E, ","))),"×"),"where Col2 is not null")))
Demo
You may try this LAMBDA() formula. You just need to adjust ranges in lambda input parameter.
=LAMBDA(UnpivotCol,AdjucentCols,QUERY(REDUCE(,REDUCE(,UnpivotCol,LAMBDA(a,x,VSTACK(a,TOCOL(INDEX(JOIN("|",INDEX(AdjucentCols,ROW(x)-(INDEX(ROW(UnpivotCol),1)-1))) & "|" & SPLIT(x,",")))))),LAMBDA(t,g,VSTACK(t,SPLIT(g,"|")))),"offset 2 format Col1 'm/d/yyyy'",0))(E2:E4,A2:D4)

How to find the highest N values in each group in Google Sheets

I want to use a formula to find the highest N values in each group in a Google Spread Sheets.
I tried this formula from infoinspired.com (credit to Prashanth):
=ArrayFormula(QUERY({SORT(A2:B;1;true;2;false);IFERROR(row(A2:A)-match(query(SORT(A2:B;1;true;2;false);"Select Col1");query(SORT(A2:B;1;true;2;false);"Select Col1");0))};"Select Col1,Col2 where Col3<3"))
But all it return is an Array_Literal error:
This is what I expect:
What is wrong with it?
You have to put a comma, not a semi colon before IFERROR. It's creating two columns, one twice larger than the other instead of three columns ;)
=ArrayFormula(QUERY({SORT(A2:B,1,true,2,false),IFERROR(row(A2:A)-match(query(SORT(A2:B,1,true,2,false),"Select Col1"),query(SORT(A2:B,1,true,2,false),"Select Col1"),0))},"Select Col1,Col2 where Col3<3"))
alternative formula:
=QUERY(SORT({{A2:B}\MAP(A2:A;B2:B;lambda(ax;bx;IFERROR(Rank(bx;Filter(B$2:$B;A$2:$A=ax);0);IFERROR(1/0))))};1;0;3;1);"Select Col1, Col2 Where Col3<3")
-

Is there a way to use arrayformula in google sheet to join text with conditions?

Is there a way to get the result column in the picture below?
All i want to do is text join the Col1 if the corresponding Col2 belongs to the same groups (E.G. 1,2,3....).
Reminded that I want to use arrayformula instead of dragging down the "normal" formula myself everytime.
Use this formula
Or Make a copy of this example sheet.
=ArrayFormula({"Result";
IF(A2:A="",,
BYROW(B2:B,
LAMBDA(v,JOIN(", ",FILTER(A2:A,B2:B=v)))))})
Great news for google-sheet lovers that google releases new lambda formulas. You can use BYROW() function to make it spill array. Try below formula.
=BYROW(C3:C9,LAMBDA(x,JOIN(",",FILTER(B3:B9,C3:C9=x))))
To refer entire column use FILTER() function for BYROW().
=BYROW(FILTER(C3:C,C3:C<>""),LAMBDA(x,JOIN(",",FILTER(B3:B,C3:C=x))))
Suppose my range of data from B3:C9, want to group the result according the the Column C (or Col2)
Here is the formula i googled without using the Lambda function
=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(FLATTEN( QUERY(QUERY({ROW(C3:C9), C3:C9&"×", B3:B9&","}, "select max(Col3) where not Col2 starts with '×' group by Col1 pivot Col2"),,7^7)), "×")), ",$", ))
Notice the 7^7 is the (length of the data)^(length of the data).
i.e. from 3 to 9, there are 7 data.

Google Sheet: How to reverse and transpose a row?

Need to reverse and transpose a row in google sheet
like below
Tried below formula but didn't reversed the order. Help me out!
=FILTER(TRANSPOSE(A1:E1),TRANSPOSE(A1:E1)<>"")
try:
=QUERY(SORT(FLATTEN(A1:1), FLATTEN(COLUMN(A1:1)), 0),
"where Col1 is not null")
or:
=INDEX(FLATTEN(VLOOKUP(ROW(A1), {ROW(A1), A1:1},
TRANSPOSE(SORT(SEQUENCE(COUNTA(A1:1))+1, 1, 0)), 0)))
=SORT(TRANSPOSE(A1:E1),SEQUENCE(COLUMNS(A1:E1)),)
SEQUENCE to create a array of sequential numbers
SORT to sort them in reverse
If you need to check for blanks, use QUERY to filter:
=QUERY(SORT(TRANSPOSE(A1:E1),SEQUENCE(COLUMNS(A1:E1)),),"where Col1 is not null",0)
Try
=query(sort(transpose({ARRAYFORMULA(column(A1:E1));A1:E1}),1,false),"select Col2")

Add Filter to Vlookup formula Google sheets

I know verry little about formulas
I have a Vlookup formula which is working
=ArrayFormula(iferror(vlookup(ConnectionHelper!M2:M, ConnectionHelper!$D$2:$E, {2,1}, false)))
I want to FILTER out rows if a cell in column D is empty
But not getting how or ever if possible!
I am trying
=Filter(ArrayFormula(iferror(vlookup(ConnectionHelper!M2:M, ConnectionHelper!$D$2:$E, {2,1}, false))),D2:D<>'')
Thanks
Try
=query(ArrayFormula(iferror(vlookup(ConnectionHelper!M2:M, ConnectionHelper!$D$2:$E, {2,1}, false))), "where Col2 <>''")
(assuming your data in column D is text).

Resources