Error parsing query from another page using current page data - google-sheets

I'm attempting to use data on another page (scholar progress reports) to match columns in a current page (copy of results).
Using the formula below:
=QUERY('Copy of Results'!$A$2:$I$999, "select D where A="&'Scholar Progress Reports'!A158&"")
Is producing the following error:
"Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: test"
where 'test' is the value of the cell I'm trying to match on the current page.

Assuming 'test' is in cell A158 of the same sheet, the query is used, try:
=QUERY('Copy of Results'!$A$2:$I$999, "select D where A='"&A158&"'", 0)
Else, try
=QUERY('Copy of Results'!$A$2:$I$999, "select D where A='"&'Scholar Progress Reports'!A158&"'", 0)

My immediate thought is exactly what the error says "NO_COLUMN: test". In your formula, are you trying to select a column, or something like that, called "test" instead of using the names "A", "B", etc.?
If that's not it, do you have a sample sheet?
THIS may also help.

Related

Google Sheet Query to pull rows with errors

I'm trying to utilize Google Sheet to pull out rows which has errors.
Below is a screenshot on how the raw data looks like (Raw Data 1):
Column A is the key, which is used in Column F to do a VLOOKUP in another tab. If not found, replace with a "-" string value, as below:
=IFERROR(VLOOKUP(A2,'Raw Data 2'!$A:$E,5,FALSE), "-")
Column G checks whether Column E = Column F.
Column H is a formula which is (F-E)/E. In this case, a "#VALUE!" error pops out due to column F, which is okay for now.
Below is my processed tab with the formula:
=QUERY('Raw Data 1'!A:J, "SELECT A,B,C,D,E,F,G,H,J WHERE F='-'")
I have also tried:
=QUERY('Raw Data 1'!A:J, "SELECT A,B,C,D,E,F,G,H,J WHERE H='#VALUE!'")
Both give me empty results. Is there a way to make the query work such that it picks up rows where the VLOOKUP in Column F fails, or when Column H returns an error?
Edit 1: I am not able to use "Filter" as my Query needs to exclude Column I.
Thanks!
Edit 2: Created a sample sheet for reference thanks to the suggestion of #player0: https://docs.google.com/spreadsheets/d/1Htj6O5VbGyRCB_X7Q0epIg8OkhrHEFYnMAH1HJckVDo/edit#gid=1568356550
Try this:
=FILTER('Raw Data 1'!A:J, 'Raw Data 1'!F:F="-")
Or:
=FILTER('Raw Data 1'!A:J, ISERROR('Raw Data 1'!H:H))
update:
=ARRAYFORMULA(QUERY(TO_TEXT('Raw Data 1'!A:J), "WHERE Col6='-'", ))

Multiple sheets query

I have a master file where I compile data from other employees
The file has 30 sheets and on that compiles them,
I'm using =Query and it's a marvellous tool however if someone calls in sick or is in a vacation I have to manually edit the formula to exclude their sheet and add it again when they come back because the query will render an error if there is no data on their sheets.
Is there a way where It can be done dynamically?
It's hard to give you exact advice since we don't know how you are aggregating your data, but what I usually would do is to wrap my queries with IFERROR. If the query is successful it won't change anything, but if it fails it will catch the error and display either nothing or whatever you tell it to display.
change your QUERY formula from this:
=QUERY({Sheet1!A:C,
Sheet2!A:C}, "select *")
to this:
=QUERY({IFERROR(Sheet1!A:C, {"","",""}),
IFERROR(Sheet2!A:C, {"","",""})}, "select * where Col1 is not null")

IMPORTRANGE: value missing?

I have been working on this issue for a few weeks now and can't seem to find a solution. I used this answer (IMPORTRANGE with CONDITIONS) to get as far as I could, but I keep getting a value error.
This is the sheet I'm working with.
My goal is to use the first tab in the sheet (All Games) to enter all the games that I come across to create a compendium. But, then I want it to automatically populate the other tabs based on certain criteria (what type of game, skills learned, etc.)
On the Warm-Ups tab you'll see the formulas I have tried. A1 is the most recent.
Here is the formula I tried:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1F64PMg_iFu-DaJAUaE4BkpqF4zoteknp56VfwAUe8ag/edit#gid=1359689553", "All Games!A1:A1300"),"SELECT Col1 WHERE (Col2 = 'w') ")
I am getting a value error:
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: Col2
you are trying to reference Col2 but you selected range A1:A1300 which is just 1 column. therefore try:
=QUERY(IMPORTRANGE("1F64PMg_iFu-DaJAUaE4BkpqF4zoteknp56VfwAUe8ag", "All Games!A1:B1300"),
"SELECT Col1 WHERE (Col2 = 'w') ")
from the brief look on your sheet, you may want use matches or contains instead of = in your QUERY
You are only importing (part of) ColumnA - so no wonder Google can't find a second column :)

IF statement inside QUERY in Google Sheets

I have a google sheet where I have several projects listed.
With a QUERY function I am retrieving information into another sheet for reporting purposes.
The formula I am using is:
=QUERY($A$2:$D$8,"IF(OR($C2=1,$C2=2,$C2=3), Select A, B, D, Select A, B, C)",0)
What I am struggling to do is placing an IF statement inside the QUERY function.
I would like to get the Date 2 (Col4) value if the Status (Col2) value is "1", "2" or "3". Otherwise, if the Status (Col2) value is "4", "5" or "6" I would like the Query to return the Date 1 (Col3)
Any help would be appreiated.
Thanks!
The formula would be like this:
=ArrayFormula(query({A2:B8,if(B2:B8<=3,D2:D8,C2:C8)},"select *"))
But the query isn't actually doing anything.
So you could just use:
=ArrayFormula({A2:B8,if(B2:B8<=3,D2:D8,C2:C8)})
So it is possible to include an IF statement into a query. The main thing to remember is that the query is text, so you have to end the quotations include your reference, and then restart the quotations. It's just like creating a sentence via formula. For an example, you would add the following text for a secondary condition:
"&if(T3="",""," and H = '"&T3&"'")&"
I wanted the ability to narrow down the results conditionally. So if I have a value in T3, then the condition for column H is added into my query. Otherwise, it is left out.
In case I messed something up or am not making sense, here's my actual complete formula. I also have the query using filters that reside in Q3,R3, and S3.
=query(Transactions!B1:H, "select B,C,D,E,F,G where B > date '"&TEXT(DATEVALUE(Q3),"yyyy-mm-dd")&"' and B <= date '"&TEXT(DATEVALUE(R3),"yyyy-mm-dd")&"' and D = '"&S3&"'"&if(T3="",""," and H = '"&T3&"'")&" order by B desc limit 50",1)

Google sheets wont filter a query

I am trying to filter a Google sheet with columns A to O using a query on a second sheet. I can put this formula in a new sheet and it pulls all the data just like its supposed to.
=query('Inventory'!$A$1:$O, "select * ", 1 )
What I am trying to do is filter the spreadsheet with a where clause that is to use a cell dropdown list (generated by unique values in the original sheet). I have used this formula:
=query('Inventory'!$A$1:$O, "select * where B = "&C1&"", 1 )
where C1 has the drop down box. This always gives me the error:
"Error
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: value" (the value depends on what is selected in the drop down).
It also doesn't work if I wrap the B = "&C1&" in parenthesis () which i have seen other posts use.
When I looked at Google's site for their example (https://support.google.com/docs/answer/3093343?hl=en), this should be a no-brainier unless something changed and their site isn't up to date.
I apologize for something this simple.
Try
=query('Inventory'!$A$1:$O, "select * where B = '"&C1&"'", 1 )

Resources