Missing Column in Google Sheets after a Query + Importrange call - google-sheets

Very simple query + importrange however, I really do not know why column I is not imported. All columns from A-J are there except for Column I.
=query({importrange("1B1uV11esy4EmHbz1DE1ApyGP6QiSa27BoPI7IHJFXBA","Budget!A5:J");
importrange("1PEI_zKRdX4Rsez-KBEmruDjJXcHxfcgWL9MwZsDqR4E","Budget!A5:J");
importrange("1r_LBfypWPy-x7Cajbed3vfp9oW_P_yCT7hOD2kAZ0Ow","Budget!A5:J");
importrange("1a5KuC7_zlfLJ498LHjgHPv6O1WHkoSwHGc1r2edodYA","Budget!A5:J");
importrange("1J_wUlThjMjsEkGDj5tUOl_eaniAHkVaz4hZXGFkT3PU","Budget!A5:J");
importrange("1DtcA8CsRk42cx4QRs4qfiPHDDFyUUeZCKqSFUhNcJhU","Budget!A5:J");
importrange("1ELTPcXc5tJh7YUX96kZBqE-jQLy7mSqVgbpygbEMZVw","Budget!A5:J");
importrange("10pG3ZuCozKeJyFWkEsM3_aGYWGXibok0_wx28FInDJI","Budget!A5:J");
importrange("1i_WT0mQJyweuhv_ObpZRalL76dbxAl9YxilMvJGngTw","Budget!A5:J")},
"Select * where Col2 is not NULL")
Can someone help me out on why this is happening?

try:
=ARRAYFORMULA(QUERY(TO_TEXT({
IMPORTRANGE("1B1uV11esy4EmHbz1DE1ApyGP6QiSa27BoPI7IHJFXBA", "Budget!A5:J");
IMPORTRANGE("1PEI_zKRdX4Rsez-KBEmruDjJXcHxfcgWL9MwZsDqR4E", "Budget!A5:J");
IMPORTRANGE("1r_LBfypWPy-x7Cajbed3vfp9oW_P_yCT7hOD2kAZ0Ow", "Budget!A5:J");
IMPORTRANGE("1a5KuC7_zlfLJ498LHjgHPv6O1WHkoSwHGc1r2edodYA", "Budget!A5:J");
IMPORTRANGE("1J_wUlThjMjsEkGDj5tUOl_eaniAHkVaz4hZXGFkT3PU", "Budget!A5:J");
IMPORTRANGE("1DtcA8CsRk42cx4QRs4qfiPHDDFyUUeZCKqSFUhNcJhU", "Budget!A5:J");
IMPORTRANGE("1ELTPcXc5tJh7YUX96kZBqE-jQLy7mSqVgbpygbEMZVw", "Budget!A5:J");
IMPORTRANGE("10pG3ZuCozKeJyFWkEsM3_aGYWGXibok0_wx28FInDJI", "Budget!A5:J");
IMPORTRANGE("1i_WT0mQJyweuhv_ObpZRalL76dbxAl9YxilMvJGngTw", "Budget!A5:J")}),
"where Col2 is not null", 0))

Related

An Arrayformula to Split the given data as shown

Please tell me the Arrayformula at C1 which converts the column A to column C,D & E as shown.
Google Sheet Link
Extra information:
Column A is actually not raw data, it is also an Arrayformula:
=ARRAYFORMULA(VLOOKUP($A:$A, TRIM(SUBSTITUTE(SPLIT(FLATTEN(QUERY(QUERY( {Sheet1!$B:$B&"^"&Sheet1!$C:$C&"^"&Sheet1!$D:$D&"#", Sheet1!$A:$A,Sheet1!$A:$A&"×"}, "select max(Col1) where Col2 is not null group by Col1 pivot Col3",1),,9^9)), "×"), "#", CHAR(10))), 2, 0))
You can check the "Sheet1" & "Extra Information" sheets to understand it.
"Sheet1" Sheet:
"Extra Information" Sheet:
This Arrayformula at B1 is what I achieved, I am not able to split this by ^ into columns as shown in 1st Image.
try in C2:
=ARRAYFORMULA(IFERROR(REGEXREPLACE(REGEXREPLACE({
VLOOKUP(A2:A, TRIM(SPLIT(FLATTEN(QUERY(QUERY({IF(Sheet1!A2:D="",,{Sheet1!A2:A&"♦", Sheet1!B2:D&"♥"}), ROW(Sheet1!A2:A)},
"select max(Col2) where Col2 is not null group by Col5 pivot Col1"),,9^9)), "♦")), 2, ),
VLOOKUP(A2:A, TRIM(SPLIT(FLATTEN(QUERY(QUERY({IF(Sheet1!A2:D="",,{Sheet1!A2:A&"♦", Sheet1!B2:D&"♥"}), ROW(Sheet1!A2:A)},
"select max(Col3) where Col2 is not null group by Col5 pivot Col1"),,9^9)), "♦")), 2, ),
VLOOKUP(A2:A, TRIM(SPLIT(FLATTEN(QUERY(QUERY({IF(Sheet1!A2:D="",,{Sheet1!A2:A&"♦", Sheet1!B2:C&"♥", TEXT(Sheet1!D2:D, "dd/mm/e")&"♥"}), ROW(Sheet1!A2:A)},
"select max(Col4) where Col2 is not null group by Col5 pivot Col1"),,9^9)), "♦")), 2, )}, "♥$", ), "♥ ", CHAR(10))))

Extracting and counting unique word frequency from a range

I have a column where each row is a sentence. For example:
COLUMN1
R1: -Do you think they'll come, sir?
R2: -Oh they'll come, they'll come all right.
R3: Here. Stamp those and mail them.
R4: It's ringing.
R5: Would you walk Myron the other way?
From this range, I want to extract a list of unique words (COLUMN2), and a count of how often they appeared in the range (COLUMN3).
The trick is to remove punctuation marks like commas, periods, etc..
So the desired result for the above would be:
COLUMN2 COLUMN3
Do 1
you 2
think 1
they'll 3
come 2
sir 1
Oh 1
all 1
right 1
Here 1
Stamp 1
those 1
and 1
mail 1
them 1
It's 1
ringing 1
Would 1
walk 1
Myron 1
the 1
other 1
way 1
I tried parsing each row with the SPLIT function, separating each word into their own cells, but I'm stuck removing the punctuation, and building the list of unique words (which I know will involve the UNIQUE function). The count I'm guessing will also involve the COUNTUNIQUE function.
Any guidance will be appreciated!
You could try something like
=query(ArrayFormula(transpose(split(query(regexreplace(A1:A5, "[^A-Za-z\s/']" ,""),,50000)," "))), "Select Col1, Count(Col1) where Col1 <>'' group by Col1 label Count(Col1)''")
Change range to suit.
If you want to exclude a list of words (ex. in the range J1:J20) you can try
=ArrayFormula(query(transpose(split(query(regexreplace(A1:A5, "[^A-Za-z\s/']" ,""),,50000)," ")), "Select Col1, Count(Col1) where not UPPER(Col1) matches '\b"&textjoin("|", 1, UPPER(J1:J20))&"\b' group by Col1 order by Count(Col1) desc label Count(Col1)''"))
Alternatively, you can also add the list of exclusions to the regex pattern...
=query(ArrayFormula(transpose(split(query(regexreplace(A1:A5, "[^A-Za-z\s/']|\b((?i)the|oh|or|and)\b" ,""),,50000)," "))), "Select Col1, Count(Col1) where Col1 <>'' group by Col1 order by Count(Col1) desc label Count(Col1)''")
UPDATED:
=ArrayFormula(substitute(query(transpose(split(query(regexreplace(substitute(C11:C, char(39), "_"), "[^A-Za-z\s_]" ,""),,50000)," ")), "Select Col1, Count(Col1) where not UPPER(Col1) matches '\b"&textjoin("|", 1, UPPER(substitute(G11:G,char(39),"_")))&"\b' group by Col1 order by Count(Col1) desc label Count(Col1)''", 0), "_", char(39)))
or, using a different approach
=query(filter(regexreplace(transpose(split(query(regexreplace(C11:C, "[^A-Za-z\s'-]" ,""),,50000)," ")), "^-",), isna(match(upper(regexreplace(transpose(split(query(regexreplace(C11:C, "[^A-Za-z\s'-]" ,""),,50000)," ")), "^-",)), upper(filter(G11:G, len(G11:G))),0))), "Select Col1, count(Col1) group by Col1 order by count(Col1) desc label count(Col1)''", 0)
You can use Mid, RegexReplace, Query, Split, etc, Like this:
= query
(
transpose
(
split
(
regexreplace ( textjoin ( " ", true,filter(mid(A11:A,4, len(A11:A)),A11:A<>"") ) , "[>,.?/!-]"," " ) ," ",true,true
)
)
,"Select Col1, Count(Col1) group by Col1 label Col1 'Column2', Count(Col1) 'Column3' "
)
or if without prefix R1: ~ R5, use like this:
= query
(
transpose
(
split
(
regexreplace ( textjoin ( " ", true,filter(A11:A,A11:A<>"")) , "[>,.?/!-]"," " ) ," ",true,true
)
)
, "Select Col1, Count(Col1) group by Col1 label Col1 'Column2', Count(Col1) 'Column3' "
)
try:
=ARRAYFORMULA(QUERY(TRANSPOSE(SPLIT(REGEXREPLACE(
TEXTJOIN(" ", 1, LOWER(A:A)), "\.|\,|\?", ), " ")),
"select Col1,count(Col1)
group by Col1
order by count(Col1) desc
label count(Col1)''", 0))
or:
=ARRAYFORMULA(QUERY(TRANSPOSE(SPLIT(REGEXREPLACE(
QUERY(LOWER(A:A),,999^99), "[^a-z0-9а-я ]", ), " ")),
"select Col1,count(Col1)
group by Col1
order by count(Col1) desc
label count(Col1)''", 0))
UPDATE:
=ARRAYFORMULA(QUERY(TRANSPOSE(SPLIT(REGEXREPLACE(
QUERY(LOWER(A:A),,999^99), "[^a-z0-9 ]", ), " ")),
"select Col1,count(Col1)
where not Col1 matches 'the|and|i|you|its'
group by Col1
order by count(Col1) desc
label count(Col1)''", 0))

Filtering within an "inner value" in Google Sheets

In Google Sheets, it's possible to sort by an "inner value", for example:
Is it also possible to do this in the "Filter" (more accurate, this would be a "having" clause), or is this option only available for sorting?
Here's a copy of an example sheet where I have the data sorted, and I'd also like to do a similar filter: https://docs.google.com/spreadsheets/d/1nfdh93lFcTHQQYB79mXGtz9huvJhvSfqTAw8GMMuEFU/edit#gid=0
=QUERY(QUERY(A:D,
"select A,sum(C) where C >= 2 group by A pivot B"),
"where Col2 is not null")
to mimic those Grand Totals from Pivot table:
=ARRAYFORMULA({{QUERY(QUERY(A:D,
"select A,sum(C) where C >= 2 group by A pivot B"),
"where Col2 is not null"),{"Grand Total";
MMULT(QUERY(QUERY(QUERY(A:D,
"select sum(C) where C >= 2 group by A pivot B"),
"where Col1 is not null"), "offset 1", 0),
ROW(INDIRECT("A1:A"&COUNTUNIQUE(B2:B)))^0)}};{"Grand Total",
TRANSPOSE(MMULT(transpose({QUERY(QUERY(QUERY(A:D,
"select sum(C) where C >= 2 group by A pivot B"),
"where Col1 is not null"), "offset 1", 0),
MMULT(QUERY(QUERY(QUERY(A:D,
"select sum(C) where C >= 2 group by A pivot B"),
"where Col1 is not null"), "offset 1", 0),
ROW(INDIRECT("A1:A"&COUNTUNIQUE(B2:B)))^0)}),
ROW(INDIRECT("A1:A"&COUNTUNIQUE(B2:B)))^0))}})

How to calculate ALL modes in a Google Sheets?

I have a data set (11,11,14,14,10).
My goal is to return all frequently appeared numbers. I used =mode() function.
But, it does not return 11 and 14, only returns 11.
Any ideas/thoughts on that?
With layout as shown,
=query(A2:A6,"select count(A), A group by A order by count(A) desc label count(A) 'frequency'")
should return a listing of all frequencies in descending order:
=QUERY(QUERY(A1:A, "select count(A), A
group by A
order by count(A) desc"),
"select Col2 where Col1 > 1", 0)
=TRANSPOSE(QUERY(QUERY(QUERY(TRANSPOSE(E1:1), "select *"),
"select count(Col1), Col1
group by Col1
order by count(Col1) desc"),
"select Col2 where Col1 > 1", 0))

How to QUERY (ImportRange) if the "where" clause also uses imported values?

I am trying to query ImportRange data by the condition that a column matches a value from the imported spreadsheet, but it does not work:
=Query(importRange("KEY1","namesheet1!A2:R1600"), "select Col4 where Col7 = (importRange("KEY1","namesheet2!F108:F108")) ",0)
Replace
"select Col4 where Col7 = (importRange("KEY1","namesheet2!F108:F108")) "
by
"select Col4 where Col7 = " & importRange("KEY1","namesheet2!F108")

Resources