I have duplicated a browser tab and I have implemented a search bar to filter only the row for the word I am looking for... however, if I don't write the exact word (lower or upper case) nothing will show up...
The formula I am using is =QUERY(IMPORTRANGE("1xxxxx8RviacxxxxxOWXx_xxxxrEi-xxxxDi_xx","Roster!B3:I"),"SELECT * WHERE Col1 CONTAINS '"&G1&"' or Col2 CONTAINS '"&G1&"' or Col3 CONTAINS '"&G1&"' or Col4 CONTAINS '"&G1&"' or Col5 CONTAINS '"&G1&"' or Col6 CONTAINS '"&G1&"' or Col7 CONTAINS '"&G1&"' or Col8 CONTAINS '"&G1&"' ")
you could try wrapping the matching columns/cell within lower to avoid this mismatch.
=ARRAYFORMULA(QUERY({to_text(IMPORTRANGE("1xxxxx8RviacxxxxxOWXx_xxxxrEi-xxxxDi_xx","Roster!B3:I"))},"SELECT * WHERE lower(Col1) CONTAINS '"&lower(G1)&"' or lower(Col2) CONTAINS '"&lower(G1)&"' or lower(Col3) CONTAINS '"&lower(G1)&"' or lower(Col4) CONTAINS '"&lower(G1)&"' or lower(Col5) CONTAINS '"&lower(G1)&"' or lower(Col6) CONTAINS '"&lower(G1)&"' or lower(Col7) CONTAINS '"&lower(G1)&"' or lower(Col8) CONTAINS '"&lower(G1)&"' "))
-
Alternate Formula:
=filter({B3:I},REGEXMATCH(BYROW(B3:I,LAMBDA(bix,TEXTJOIN("|",1,bix))),"(?i)"&G1))
try:
=LAMBDA(x, FILTER(x, REGEXMATCH(FLATEN(QUERY(TRANSPOSE(x),,9^9)), "\b"&G1&"\b")))
(IMPORTRANGE("1xxxxx8RviacxxxxxOWXx_xxxxrEi-xxxxDi_xx", "Roster!B3:I"))
or insensitive:
=LAMBDA(x, FILTER(x, REGEXMATCH(FLATEN(QUERY(TRANSPOSE(x),,9^9)), "(?i)\b"&G1&"\b")))
(IMPORTRANGE("1xxxxx8RviacxxxxxOWXx_xxxxrEi-xxxxDi_xx", "Roster!B3:I"))
Related
Suppose I have a column of words, in some cases more than 1 word in each cell, separated by a comma or space. I want to calculate the number of words starting with A, B, C...,Z separately.
try:
=ARRAYFORMULA(QUERY(IFERROR(FLATTEN(REGEXEXTRACT(SPLIT(A1:A10; ", "); "^.")));
"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1)''"))
or:
=ARRAYFORMULA(QUERY(IFERROR(UPPER(FLATTEN(REGEXEXTRACT(SPLIT(A1:A10, ", "), "^.")))),
"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1)''"))
Is there a better way of writing this formula out? I mean it works but there has to be a better way of doing it where I can have multiple Search parameters.
I am using a search box to then that splits the cell with this formula =if(E1="","", if(REGEXMATCH(E1,";"),SPLIT(E1,";"),E1))
https://docs.google.com/spreadsheets/d/1-ymDylwRjd0zYnu3m0uxCz8hAavnL5Sxx39YrtlWylc/edit?usp=sharing Example Sheet
=if(E1="",QUERY(IMPORTRANGE("Spreadsheetidabcd", "RawData!A:Z"), "Select Col1,Col12,Col2,Col10,Col3 where (Col11='')",1),QUERY(IMPORTRANGE("Spreadsheetidabcd", "RawData!A:Z"), "Select Col1,Col12,Col2,Col10,Col3 where Col1 contains '"&$F$1&"' or Lower(Col12) contains Lower('"&$F$1&"') or Lower(Col12) contains Lower('"&$G$1&"')or Lower(Col10) contains Lower('"&$F$1&"')or Lower(Col10) contains Lower('"&$G$1&"')or Lower(Col2) contains Lower('"&$F$1&"')or Lower(Col2) contains Lower('"&$G$1&"')or Col3 contains '"&$F$1&"' or Col3 contains '"&$G$1&"'or Col4 contains '"&$F$1&"'or Lower(Col5) contains Lower('"&$F$1&"')"))
You can try this one, although this returns the row if any of the columns contain the values of either F1 or G1 (I assume that's what your search box is for, to find the rows containing the search term).
Formula:
=if(E1="",
QUERY(IMPORTRANGE("Spreadsheetidabcd", "RawData!A:Z"), "Select Col1,Col12,Col2,Col10,Col3 where (Col11='')",1),
arrayformula(split(query({transpose(split(textjoin(",", true, QUERY(IMPORTRANGE("Spreadsheetidabcd", "RawData!A:Z"), "Select Col1, Col12, Col2, Col10, Col3, ';' label ';' ';'")), ",;,",))}, "where lower(Col1) contains lower('"&$F$1&"') or lower(Col1) contains lower('"&$G$1&"') or Col1 contains 'Timestamp'"), ",")))
Basically, what the formula does step by step is:
It appends a column that marks the end of the row when we combine them into 1 column.
Combines all columns into 1 using , as delimiter (, marks per column and ; marks per row)
Then we split them by ,;, to separate each rows (each row contains the textjoined result)
After that, we filter the data using query where a row should contain the values of F1 and G1 (and including Timestamp to include the header).
Filtered data will then split back to their original form
Output:
EDIT:
To be dynamic, I modified it to check F1:1 range instead.
Formula:
=if(E1="",
QUERY(IMPORTRANGE("Spreadsheetidabcd", "RawData!A:Z"), "Select Col1,Col12,Col2,Col10,Col3 where (Col11='')",1),
arrayformula(split(query({transpose(split(textjoin(",", true, QUERY(IMPORTRANGE("Spreadsheetidabcd", "RawData!A:Z"), "Select Col1, Col12, Col2, Col10, Col3, ';' label ';' ';'")), ",;,",))}, "where lower(Col1) contains lower('"&join("') or lower(Col1) contains lower('", filter($F$1:$1, not(isblank($F$1:$1))))&"') or Col1 contains 'Timestamp'"), ",")))
Output:
With the data in the attached google sheet, Col F (IN/OUT) will have either IN or OUT and Col J (Bag Numbers) will have numbers seperated by Comma.
Based on the sample data, for Vendor 4-Sunil, Bag numbers 2,3,4,5 where sent OUT on 8/9/21. On 17/9/21, 2,3,4,5 where received IN. So there is nothing Pending with Vendor 4-Sunil.
On the other hand with Vendor 5-Rajan, Bag numbers 13,14,15,16 where sent OUT on 14/9/21. On 25/9/21 Bag Numbers 13,15 where received IN. So the pending bags yet to be received IN from Vendor 5-Rajan is 14,16.
Is there a way to build a formula in Google sheet to indicate the number of pending Bags based on IN or OUT criteria for a given Vendor?
Thank you.
Sample Google sheet
https://docs.google.com/spreadsheets/d/10XP3k4HLteGHgOEdd0YIZR-_0p2IiHog5R7luIM5NeM/edit?usp=sharing
To display Bag numbers out, try:
=arrayformula(query({
query({A:J},"select Col5 where Col5 !='' and Col6 contains 'OUT' order by Col5",1),
regexreplace(regexreplace(regexreplace(query({A:J},"select Col10 where Col5 !='' and Col6 contains 'OUT' order by Col5",1),iferror(vlookup(query({A:J},"select Col5 where Col5 !='' and Col6 contains 'OUT' order by Col5",1),{query({A:I,iferror(regexreplace(J:J,",","|"),J:J)},"select Col5, Col10 where Col5 !='' and Col6 contains 'IN' order by Col5",1)},2,0)),""),",+",","),"^,+|,+$",)
},"where Col2 != '' label Col2 'Remaining out' ",1))
If you want a more complex solution running from a single cell that handles multiple OUT and IN for the same Vendor, then try:
=arrayformula({"Vendor","Items still out";regexreplace(query({
query(regexreplace(split(flatten(regexreplace(trim(query(transpose(query(if(E2:E<>"",substitute({E2:E&char(9998)&F2:F&char(9998),J2:J,J2:J}," ",char(9999)),),"select Col1,Max(Col2) where Col1 !='' group by Col1 pivot Col3",)),"",9^9))," ",",")),char(9998)),"^,+|,+$",),"select Col1 where Col2 contains 'OUT' order by Col1",0),
iferror(regexreplace(regexreplace(query(regexreplace(split(flatten(regexreplace(trim(query(transpose(query(if(E2:E<>"",substitute({E2:E&char(9998)&F2:F&char(9998),J2:J,J2:J}," ",char(9999)),),"select Col1,Max(Col2) where Col1 !='' group by Col1 pivot Col3",)),"",9^9))," ",",")),char(9998)),"^,+|,+$",),"select Col3 where Col2 contains 'OUT' order by Col1",0),iferror(vlookup(
query(regexreplace(split(flatten(regexreplace(trim(query(transpose(query(if(E2:E<>"",substitute({E2:E&char(9998)&F2:F&char(9998),J2:J,J2:J}," ",char(9999)),),"select Col1,Max(Col2) where Col1 !='' group by Col1 pivot Col3",)),"",9^9))," ",",")),char(9998)),"^,+|,+$",),"select Col1 where Col2 contains 'OUT' order by Col1",0),
{regexreplace(query(regexreplace(split(flatten(regexreplace(trim(query(transpose(query(if(E2:E<>"",substitute({E2:E&char(9998)&F2:F&char(9998),J2:J,J2:J}," ",char(9999)),),"select Col1,Max(Col2) where Col1 !='' group by Col1 pivot Col3",)),"",9^9))," ",",")),char(9998)),"^,+|,+$",),"where Col2 contains 'IN' order by Col1",0),",","|")}
,3,0),),),"^,+|,+$",),)
},"where Col2 !='' ",0),char(9999)," ")})
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)))
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.