I have a Google Sheet tab ("Data") with columns A:Z and need to create a tab that pulls in all rows from ("Data") if columns A:N are NOT null in any of these columns.
I've tried query importrange, query+importrange, but can't crack the code:
Attempt #1: =IF(isblank("Data!A1:N1"),Importrange("https:...
","Data!A1:Z100"),,))
Attempt #2: =QUERY(IMPORTRANGE("https:...",
" Data!A1:Z1"), "select Col1 where Col1 is not Null", 0). <<this pulls the data in for that specific cell but I can't drag it down or across to get the other rows to populate
Help!
join columns A:N into one column and use TRIM
=INDEX(TRIM(FLATTEN(QUERY(TRANSPOSE(IMPORTRANGE("url", "Data!A1:N")),,9^9))))
next, add this column to the range A:Z as the last column of array {} and QUERY it
=INDEX(ARRAY_CONSTRAIN(QUERY({
IMPORTRANGE("url", "Data!A1:Z"), TRIM(FLATTEN(QUERY(TRANSPOSE(
IMPORTRANGE("url", "Data!A1:N")),,9^9)))},
"where Col27 is not null"), 9^9, 26))
Related
How can I combine 2 spreadsheets into one without any gaps? When I import range 2 sheets, there is a gap of ~1000 rows. To make sure there are no gaps between the 2 sheets, I usually create a query "Where Col1 is not null " but I am missing some info. :(
My spreadsheet: https://docs.google.com/spreadsheets/d/1aSnbySwNPEvkkXqw6ItuBpZ_6-o58HPlVicIHWD0Y4I/edit#gid=381064131
Thanks in advance.
You can use just being three columns:
=query({
importrange("https://docs.google.com/spreadsheets/d/1aSnbySwNPEvkkXqw6ItuBpZ_6-o58HPlVicIHWD0Y4I/edit#gid=0", "Sheet1!A2:C");
IMPORTRANGE("https://docs.google.com/spreadsheets/d/1aSnbySwNPEvkkXqw6ItuBpZ_6-o58HPlVicIHWD0Y4I/edit#gid=0", "Sheet2!A2:C")}, "Select * WHERE Col1 IS NOT NULL OR Col2 is not null OR Col3 is not null")
A second possible scenario for avoiding empty rows, no matter how many columns you have is wrapping your range or query in LAMBDA, and use FILTER associated with BYROW and COUNTA. If there are no elements in any row, then the count will be 0 and it will be filtered out:
=LAMBDA(quer,FILTER(quer, BYROW (quer, LAMBDA (each,COUNTA(each)))))({
importrange("https://docs.google.com/spreadsheets/d/1aSnbySwNPEvkkXqw6ItuBpZ_6-o58HPlVicIHWD0Y4I/edit#gid=0", "Sheet1!A2:C");
IMPORTRANGE("https://docs.google.com/spreadsheets/d/1aSnbySwNPEvkkXqw6ItuBpZ_6-o58HPlVicIHWD0Y4I/edit#gid=0", "Sheet2!A2:C")})
Both solutions return:
I have the yellow table shown below, and I'm trying to get the blue table, which aggregates columns B:F by value, and then counts the number of 'x' symbols for each row value of column A.
Is there some basic SQL/array magic formula to get this, please? There must be.
Use this new functions formula
=BYROW(B2:4, LAMBDA(v, COUNTIF(v, "=x")))
Used:
BYROW, LAMBDA, COUNTIF
v is the array_or_range
Update
={ A2:A4, BYROW(B2:4, LAMBDA(vv, COUNTIF(vv, "=x")))}
For fun
Update 02
=ArrayFormula(TRANSPOSE(QUERY({
QUERY(TRANSPOSE(IF(A1:4<>"x",A1:4,1)),
" Select * Where Col1 is not null ", 1)},
" Select (Col1),sum(Col2),sum(Col3),sum(Col4) Group by Col1 ", 1)))
Right now I am using this query to search for a row based on its Column 1 value. Then it takes the value from the last column. I need a way for it to automatically find the last column in the row since some of the rows have more columns than others.
This is what I had before, which I had manually specified the last column with a value:
=QUERY(IMPORTRANGE("link_redacted","PriceList!A1:AZ100000"), "Select Col10 where Col1 = '5531001'",1)
I have tried using LOOKUP with ARRAYFORMULA I couldn't get it to work:
=QUERY(IMPORTRANGE("link_redacted","PriceList!A1:AZ100000"), "Select (LOOKUP(1, ARRAYFORMULA(1/[Select Col1 where Col1 = '5531006']:[Select Col100 where Col1 = '5531006']<>"")[Select Col1 where Col1 = '5531006']:[Select Col100 where Col1 = '5531006']))",1)
Any ideas for a simpler way to do this?
Since no example is presented, I tested the formulas given but no source data is fetched.
so i created a a minimal, reproducible example
Example is the data on the left
Use this formula to get the last non empty columns values.
=ArrayFormula(IFERROR( REGEXEXTRACT( TRIM(TRANSPOSE(QUERY(TRANSPOSE(C3:E),,ROW(C3:E)))), "[^\s]+$")))
Hi everyone,
I have 3 tables with different number of columns where some columns are actually repeated in these 3 tables (as shown in the screenshot above).
Table 1: Col A to Col D
Table 2: Col F to Col H
Table 3: Col J to Col L
I want to merge these 3 tables together to reduce the number of columns in my google sheet. The screenshot below is how I process these 3 tables before merging.
I'm using QUERY to create extra columns for each table so that the number of columns and the position are aligned between 3 tables. After that, I use QUERY again to append the 3 processed tables as shown in the screenshot below:
However, this method is very tedious when I have 10 tables or more. Is there any other easier ways or tricks to use so that I can achieve the same expected output as shown in the 3rd screenshot?
This is my sheet:
https://docs.google.com/spreadsheets/d/1H1gJAhp1RVax2fy8D-uEtFxdjb-zAHutkPFv5WZT_TY/edit#gid=0
Any help will be greatly appreciated!
You would need a really complicated formula to get the desired output which is a combination of multiple formula's
I added a new tab in you Google Sheet called "Solution" with this formula included
=QUERY(ARRAYFORMULA({
IFERROR( ArrayFormula(SPLIT(FLATTEN(Sheet1!B3:D3&"~"&Sheet1!A4:A&"~"&Sheet1!B4:D),"~")),"");
IFERROR( ArrayFormula(SPLIT(FLATTEN(Sheet1!G3:H3&"~"&Sheet1!F4:F&"~"&Sheet1!G4:H),"~")),"");
IFERROR( ArrayFormula(SPLIT(FLATTEN(Sheet1!K3:L3&"~"&Sheet1!J4:J&"~"&Sheet1!K4:L),"~")),"")}),
"SELECT Col2, SUM(Col3) WHERE Col2 is not null GROUP BY Col2 PIVOT Col1 LABEL Col2 'Student Name' ")
Steps:
Unpivot each table =IFERROR( ArrayFormula(SPLIT(FLATTEN(Sheet1!B3:D3&"~"&Sheet1!A4:A6&"~"&Sheet1!B4:D6),"~")),"")
Combine all tables into one table: =ARRAYFORMULA({__Unpivot1__; __Unpivot2__, __Unpivot3__})
Pivot above data in Step2: =Query(__Step2__, "SELECT Col2, SUM(Col3) GROUP BY Col2 PIVOT Col1 LABEL Col2 'Student Name' ")
Add WHERE Col2 is not null in the query to remove any possible blank rows
I have data in columns A:F and unique entries in column H. I'm using the data in column H to filter it's data from the first two columns and return data in the 5th and 6th columns (E and F).
I have tried and got myself a working formula but it's incomplete to get me the data I need. The formula is:
=IFERROR(QUERY(INDEX(SORT(FILTER({E2:E, ROW(A2:A)}, (A2:A=H2)+(B2:B=H2)), 2, 0),,1),,100000))
*The query function is to allow more than 50000 characters in that happens.
Please check out my data in this google sheets file to better understand.
https://docs.google.com/spreadsheets/d/1hGy_bIAzKj8Qq0l2BGu2ya6mrYaD7pmixPQISzunHrI/edit?usp=sharing
delete E:F and use this in E2:
=ARRAYFORMULA(IF(A2:A="",,"<td class="""&
IF(C2:C>D2:D, {"win", "loss"},
IF(C2:C<D2:D, {"loss", "win"}, "draw"))&"""></td>"))
then use this and drag down:
=ARRAYFORMULA(QUERY(INDEX(QUERY(SORT({SPLIT(QUERY(
FLATTEN(IF($A$2:$B="",,$A$2:$B&"×"&$E$2:$F)),
"where Col1 is not null"), "×"), SEQUENCE(COUNTA($A$2:$B))}, 3, 0),
"where Col1 = '"&H2&"'"),,2),,9^9))