1

I'm trying to query two separate sheets to a cell in my budget. One of the sheets is a google form I use to track my daily cash transactions, and the other is a ledger I'm using to input my bank transactions.

If I query either one of the sheets like this, either works fine:

=SUM(QUERY('Form Responses'!$A$1:$C$400,"SELECT B,C WHERE B = 'Coffee'",1))/$D$1
=SUM(QUERY(Ledger!$A$1:$C$400,"SELECT B,C WHERE B = 'Coffee'",1))/$D$1

HOWEVER, when I try to combine them like this...

=SUM(QUERY({'Form Responses'!$A$1:$C$400;Ledger!$A$1:$C$400},"SELECT B,C WHERE B = 'Coffee'",1))/$D$1

I get this error:

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

I have gone deep into forums and SO, and have found lots of tips - but none of them work and many of them are depreciated. Can anyone solve this issue at a glance?

I don't understand how there can be a 'Column B' when they're queried individually, but not when queried together.

player0
  • 124,011
  • 12
  • 67
  • 124
Haytorade
  • 155
  • 1
  • 14
  • 1
    When you use an array of data for `query()` - you should use `Col1`, `Col2`, etc., instead of `A`,`B`, etc. In your case `"SELECT Col2, Col3 WHERE Col2 = 'Coffee'"` should help. – Sergey Nov 10 '21 at 06:36
  • Does this answer your question? [Google spreadsheet Query Error - column doesn't exist](https://stackoverflow.com/questions/11650331/google-spreadsheet-query-error-column-doesnt-exist) – Emel Nov 10 '21 at 08:18

1 Answers1

1

use:

=SUM(QUERY({'Form Responses'!$A$1:$C$400; Ledger!$A$1:$C$400},
 "select Col2,Col3 where Col2 = 'Coffee'", 1))/$D$1
player0
  • 124,011
  • 12
  • 67
  • 124