Trouble decoding error in Sheets formula for data transfer

Hey everyone! I’m stuck with a problem in Google Sheets. I’m trying to move some info from one sheet to another using a query. Here’s what I’ve got:

=query(IMPORTRANGE("1ABxxxxxxxx-DEfyyyyyyyy-zzzzzz","DataSheet!A4:AI1000"),"select Col1, Col2, Col3, Col5, Col7, Col9, Col14, Col16, Col 18, Col19, Col20, Col21 where Col35 = 'Yes'")

But I’m getting this weird error:

Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " <INTEGER_LITERAL> "18 "" at line 1, column 62. Was expecting one of: <EOF> "where" ... "group" ... "pivot" ... "order" ... "skipping" ... "limit" ... "offset" ... "label" ... "format" ... "options" ... "," ... "*" ... "+" ... "-" ... "/" ... "%" ... "*" ... "/" ... "%" ... "+" ... "-" ...

I’m totally lost here. What’s going wrong? The sheet I’m pulling from has columns A to AI, and I figured A4:AI1000 would grab everything I need. Any ideas what’s causing this?

I’ve encountered similar issues with QUERY functions before. The problem seems to be in your column selection syntax. There’s an extra space in ‘Col 18’ which is causing the parse error. Try removing that space:

=query(IMPORTRANGE(“1ABxxxxxxxx-DEfyyyyyyyy-zzzzzz”,“DataSheet!A4:AI1000”),“select Col1, Col2, Col3, Col5, Col7, Col9, Col14, Col16, Col18, Col19, Col20, Col21 where Col35 = ‘Yes’”)

Also, ensure your IMPORTRANGE function is authorized. Sometimes these errors can occur if the connection between sheets isn’t properly established. If the issue persists, double-check your column numbers and make sure they exist in the source sheet. Hope this helps!

I’ve dealt with similar QUERY headaches before. One thing to keep in mind is that IMPORTRANGE can be finicky with large datasets. Instead of A4:AI1000, try limiting your range to just the columns you need. Something like:

=query(IMPORTRANGE("1ABxxxxxxxx-DEfyyyyyyyy-zzzzzz","DataSheet!A4:AI35"),"select Col1, Col2, Col3, Col5, Col7, Col9, Col14, Col16, Col18, Col19, Col20, Col21 where Col35 = 'Yes'")

This might help with performance and reduce the chance of errors. Also, double-check that your source sheet actually has 35 columns. Sometimes, hidden columns can throw things off. If you’re still stuck, try breaking down the formula into smaller parts and testing each separately. It’s a pain, but it can help pinpoint where things are going wrong.

hey Oscar64, i think i see the issue. you’ve got an extra space in ‘Col 18’ that’s messing things up. try this:

=query(IMPORTRANGE(“1ABxxxxxxxx-DEfyyyyyyyy-zzzzzz”,“DataSheet!A4:AI1000”),“select Col1, Col2, Col3, Col5, Col7, Col9, Col14, Col16, Col18, Col19, Col20, Col21 where Col35 = ‘Yes’”)

that should fix it. let me know if it works!