When I use the query function in Google sheets it works fine until I try to add WHERE condition. I want to only pull data that contains a TRUE value in Column 10. Right now my query function can pull all of the data but when I try to add the WHERE condition the query does not pull any data even though there are TRUE values in Column 10.
I have tried using the WHERE condition to pull values from different columns and it has been unsuccessful. Anytime I try to add the WHERE condition in my query formula no data is pulled.
Below code works to pull all data:
=QUERY({RepTemplate1!A4:AC63;RepTemplate2!A5:AC64},"SELECT Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Col10, Col11",1)
Below code does NOT work to pull specified data:
=QUERY({RepTemplate1!A4:AC63;RepTemplate2!A5:AC64},"SELECT Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Col10, Col11 WHERE Col10 = 'TRUE'",1)
There is no error message for the formula that is not working. The headers appear just no data.
Not sure where I am going wrong.
Google Sheets reads TRUE as boolean and not string. So you may want to try the same query without the single quotation marks:
=QUERY({RepTemplate1!A4:AC63;RepTemplate2!A5:AC64},"SELECT Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Col10, Col11 WHERE Col10 = TRUE",1)
or try FILTER:
={RepTemplate1!A4:K4;
FILTER({RepTemplate1!A5:K63; RepTemplate2!A5:K64},
{RepTemplate1!J5:J63; RepTemplate2!J5:J64}=TRUE)}
Related
I have merged the Two Queries to convert the 1 of the Column values (which are dates) into check and Uncheck.
If column has date it will be check anf if its empty it will uncheck.
=ARRAYFORMULA(QUERY({DATA!A3:BB},IF(ISDATE_STRICT(QUERY({(DATA!G3:G)})), "Check", "Uncheck")}, "SELECT Col1, Col2, Col3, Col4, Col5, Col6, Col7", 0))
your help will be much appreciated.
Please try:
=ARRAYFORMULA(QUERY({DATA!A3:BB,IF(ISDATE_STRICT(DATA!G3:G), "Check", "Uncheck")}, "SELECT Col1, Col2, Col3, Col4, Col5, Col6, Col7", 0))
If you're trying to grab columns A to F and convert G column next to them, you may keep it more simple outside of the QUERY with curly brackets:
={DATA!A3:F,ARRAYFORMULA(IF(ISDATE_STRICT(DATA!G3:G),"Check", "Uncheck"))}
Let me know!
I'm having a google sheet query working well for me in my Android mobile....
=QUERY(ARRAYFORMULA(IFERROR(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(UNIQUE({IMPORTHTML("https://niftyinvest.com/indices","Table",1);IMPORTHTML("https://niftyinvest.com/indices","Table",2);IMPORTHTML("https://niftyinvest.com/indices","Table",3);IMPORTHTML("https://niftyinvest.com/indices","Table",4)}),"arrow_drop_up"," "),"arrow_drop_down",""),"*",""))),"Select Col1, Col4, Col7, Col3, Col6, Col9, Col10")
Now I want it to get auto refreshed every 20min. Can anyone help me plz ??
Plz remember I'm using Android mobile.
try:
=QUERY(ARRAYFORMULA(IFERROR(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(UNIQUE({
IMPORTHTML("https://niftyinvest.com/indices","Table",1);
IMPORTHTML("https://niftyinvest.com/indices","Table",2);
IMPORTHTML("https://niftyinvest.com/indices","Table",3);
IMPORTHTML("https://niftyinvest.com/indices","Table",4)}),
"arrow_drop_up"," "),"arrow_drop_down",""),"*",""))),
"Select Col1, Col4, Col7, Col3, Col6, Col9, Col10", ROUND(NOW()-NOW()))
with:
The formula converts negative into positive and vice versa, but how can I get all numbers in Col8 to be positive?
=query(UNIQUE(IMPORTRANGE("https://docs.google.com/spreadsheets/d/ddddddddddddsssssssssssssssswwwwwwww/edit";"Sheet1!A1:K"));"select Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col8*-1 where Col2 matches '"&B6&"' label Col8*-1 'Qtd' ")
Here's a copy of the sheet
Would there be an ABS() equivalent here?
Thank you!
try:
=INDEX(QUERY(UNIQUE({
IMPORTRANGE("1uU9zw9BbXp5hOO1f8fZEcgc8f8u8uZNjoeeuHI3SBpM"; "Sheet1!A1:K")\ABS(
IMPORTRANGE("1uU9zw9BbXp5hOO1f8fZEcgc8f8u8uZNjoeeuHI3SBpM"; "Sheet1!H1:H"))});
"select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col12
where Col1 is not null label Col12'Qty'"))
I'm trying to create a query in which I can convert some data from text to numbers, here is what i've done for now :
=QUERY(ARRAYFORMULA(IFERROR(REGEXREPLACE('Input'!D:S;"\.";","))); "select Col1, Col2, Col3, Col13, Col16 WHERE Col13 = 'NET A PAYER' ";1)
This is perfect for changing dot to commas for locale. But when I'm trying to SUM(Col16), this is not working because format of Col16 is text. And I can't CNUM, TO_PURE_NUMBER, *1 because of range where regexreplace is applied. I understand that it's applied for D to S, but I only want it on S.
So, here is my request ! Is it possible within data selection to do something like =QUERY('Input'!D:ARRAYFORMULA(IFERROR(REGEXREPLACE(S;"\.";",")*1)); "select Col1, Col2, Col3, Col13, Col16, SUM(Col16) WHERE Col13 = 'NET A PAYER' ORDER BY Col13 ";1)
Here is some data test accessible : https://docs.google.com/spreadsheets/d/1Vt1dDHzRPwP2tuL5bsqjaE9TJHwL469OddzSeRKk4jU/edit?usp=sharing
I'm hard stuck on it...!
Thanks for your help !
Try
=QUERY({A:C \ ARRAYFORMULA(SUBSTITUTE(D:D;".";",")*1)}; "select Col1, Col2, Col3, Col4 WHERE Col1 = 'NET A PAYER' label Col4 'Gain' ";1)
or to do the summing in the query directly
=QUERY({A:C \ ARRAYFORMULA(SUBSTITUTE(D:D;".";",")*1)}; "select Col1, Col2, Col3, sum(Col4) WHERE Col1 = 'NET A PAYER' group by Col1, Col2, Col3 label sum(Col4) 'Gain' ";1)
See if that works for you?
Here's a QUERY that works:
=QUERY(IMPORTRANGE("[key omitted]", "'FORM RESPONSES 1'!A1:G999"),
"Select Col1, Col2, Col3, Col4, Col5, Col6, Col7",
1)
This is just the same, but I added a "where" and a condition:
=QUERY(IMPORTRANGE("[key omitted]", "'FORM RESPONSES 1'!A1:G999"),
"Select Col1, Col2, Col3, Col4, Col5, Col6, Col7 where Col1 <> 'foo'",
1)
When I run the second query, instead of showing all rows of the source spreadsheet, only the first row is shown. There is no "foo" in my data, so all rows should be shown, just like in the first. I looked at examples, and this seems to be valid syntax.
What do you suppose is happening?
Instead of QUERY, try FILTER, like this:
=IFERROR(filter(
IMPORTRANGE("[Key Omitted]","'Form Responses 1'!A1:G999"),
NOT(IFERROR(
SEARCH(
"foo",
IMPORTRANGE("[Key Omitted]","'Form Responses 1'!A1:A999")
)
))
))