1
votes

According to the Google Help Section I should be able to reference a column in a QUERY by using the "column identifiers ... the one or two character column letter (A, B, C, ...)" - or in this case, G.

The goal of my query is simply to pull information into a new spreadsheet from columns H, J, and K of a different spreadsheet if G is equal to a certain name; in this case, William.

My query:

=QUERY( Survey!G2:K , "select G, H, J, K where G = 'William'" )

works when I use it to call information from a sheet in the same spreadsheet. The problem arises when I try to use this QUERY with IMPORTRANGE. I have used both of these formulas:

=QUERY(IMPORTRANGE("key","'Survey!G2:K'"),"SELECT G, H, J, K WHERE G='William'")

=QUERY(IMPORTRANGE("key","'Survey!Col7:Col11'"),"SELECT Col7, Col8, Col10, Col11 WHERE Col7='William'")

and both return errors. I have included a link to the error that appears for the first QUERY The second error says the same thing, with Col7 replacing G in the text.

What should I be calling the columns in the QUERY?

Is this error due to a problem in my IMPORTRANGE overall?

2

2 Answers

1
votes

Please include a link to your sheet.

The Col notation should only go inside the QUERY, not the IMPORTRANGE.

Try this:

=query(importrange("Survey!G2:K"),"Select * where Col7 = 'William'")

0
votes

This may not be but shows signs of being lack of authorsation. Try IMPORTRANGE on its own and see whether you need to grant access (once off) to the 'other' spreadsheet.