Query returning error Unable to parse query string for Function QUERY parameter 2: NO_COLUMN

Dan picture Dan · Jul 11, 2019 · Viewed 9.1k times · Source

I am currently working in the following spreadsheet

https://docs.google.com/spreadsheets/d/13KfjUhWSB-BjGyC1G8f8i8o4SPd1kFFLkjN7D6VY8Lk/edit#gid=993210576

In which I am importing data from another worksheet using IMPORTRANGE, and writing a QUERY to match the cells in column B, which correspond to a specific part number, to their corresponding cut quantity found in Column D of the imported sheet. The query I have written is as follows.

=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1kFK-ZW8QjtsLYY5twdoMNTdqobGNWIV8nAFBRdouE28/edit#gid=473793446", 
 "FABRICATION LOG!A78169:K"), "Select Col3 where Col4 = "&B3&" limit 1", 0)`

And is returning the error message:

Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: WFR332703

I have used ImportRange for the sheet I am linking to in sheet1 of the spreadsheet linked above, and allowed access, so the error is not there.

Sheet1 is there to display the values returned for the IMPORTRANGE so that I can manually look up values I am expecting to get. Now for some of these cells, I expect to not get a value, as these will not be in the sheet I'm importing. But for others, I am expecting a numerical value, which is not being returned. I suspect this may have something to do with the fact that there is a mismatch between Datatypes since the entries in column b are both letters and numbers, but this is only a hunch with no actual facts to back it up. If anyone has any suggestions It'd be greatly appreciated.

Answer

player0 picture player0 · Jul 11, 2019

first, paste this into some cell and connect you sheets by allowing access:

=IMPORTRANGE("1kFK-ZW8QjtsLYY5twdoMNTdqobGNWIV8nAFBRdouE28", "FABRICATION LOG!A1")

then use the formula:

=QUERY(IMPORTRANGE("1kFK-ZW8QjtsLYY5twdoMNTdqobGNWIV8nAFBRdouE28", 
 "FABRICATION LOG!A78169:D"), 
 "select Col3 
  where Col4 = '"&B3&"' 
  limit 1", 0)

if cell B3 is number use:

=QUERY(IMPORTRANGE("1kFK-ZW8QjtsLYY5twdoMNTdqobGNWIV8nAFBRdouE28", 
 "FABRICATION LOG!A78169:D"), 
 "select Col3 
  where Col4 = "&B3&" 
  limit 1", 0)