Querying an imported range works until I add any condition - google-sheets

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")
)
))
))

Related

Getting an formula Prase Error while Merging Two Queries

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!

When importing HTML into Google Sheets, there are issues with the order by and select col functions as well as the header

I am using this function =QUERY(INDEX(SUBSTITUTE(IMPORTHTML (I2 & "?refresh=" & I6,I3,I4), "*", )), "SELECT Col1, Col2, Col3, Col4 ORDER BY Col1 ASC")
This is returning data with the headers in between the table.
Also, can we use offset to avoid headers at all, if yes what would be proper syntax Link to importing page
https://ipowala.in/ipo-subscription-status/
You might as well do all of the work inside a QUERY
=ARRAYFORMULA(
QUERY(
SUBSTITUTE(
IMPORTHTML("https://ipowala.in/ipo-subscription-status/?refresh="&I6,"table",1),
"*",""),
"select Col1, Col2, Col3, Col4
where not Col1 = 'IPO Name'
order by Col1",0))
This will ditch the headers
If you wanted to remove the * while retaining the actual values, it's a little different. We can leverage the error on converting to values (the double hyphens) and run the substitute in that.
=ARRAYFORMULA(
QUERY(
IFERROR(
--IMPORTHTML("https://ipowala.in/ipo-subscription-status/?refresh="&I6,"table",1),
SUBSTITUTE(
IMPORTHTML("https://ipowala.in/ipo-subscription-status/?refresh="&I6,"table",1),
"*","")),
"select Col1, Col2, Col3, Col4
where not Col1 = 'IPO Name'
order by Col1",0))

Query Google sheet, format column text to number in data selection before Select

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?

Google Sheets QUERY reference a single cell value as a static column

I have the following example spreadsheet: https://docs.google.com/spreadsheets/d/1uv0Lj5sayraH4FOPE1qZ3coLA9A2incLuX2JYD5y7SQ/edit?usp=sharing
I have a query on Sheet 2 that references sheet1 and sheet2. I would like to have the query return 3 columns, Name, ID, and GroupName. GroupName should reference A1 from the sheet.
I cannot find a way to do this, but it seems that it should be possible.
Something like
=query({Sheet1!A:B; Sheet2!A:B},"Select Col1, Col2, A1 Col3 where Col1 is not null")
Try:
=arrayformula(query({iferror(Sheet1!A2:A/0,Sheet1!A1),Sheet1!A2:B; iferror(Sheet2!A3:A/0,Sheet2!A1),Sheet2!A3:B},"where Col2 is not null label Col1 'GroupName'",1))
You can alter the column order like this (select Col2, Col3, Col1):
=arrayformula(query({iferror(Sheet1!A2:A/0,Sheet1!A1),Sheet1!A2:B; iferror(Sheet2!A3:A/0,Sheet2!A1),Sheet2!A3:B},"select Col2, Col3, Col1 where Col2 is not null label Col1 'GroupName'",1))
I was able to get it to work by swapping the semi-colon for a comma
=query({Sheet1!A:B, Sheet2!A:B},"Select Col1, Col2, Col3 where Col1 is not null")
Col3 should be col A from sheet2

Query function not working when I add WHERE in formula

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)}

Resources