5

My query is yielding an error

#N/A Query Completed with an Empty Output.

=sum((query(importrange("mysheet","CR"),"select Col7 where Col1 ='"&A4&"' and Col2 ='"&B4&"' and Col13!='Cancelled' and Col13!='Rejected' ",0)))

The function is working properly when data exists in the referenced sheet. The issue is as I drag it down some of the column references don't exist in the CR data set. How do I get a zero to populate instead of the error?

player0
  • 124,011
  • 12
  • 67
  • 124
Elizabeth
  • 57
  • 1
  • 8

1 Answers1

6

you need to use IFERROR like this which will result in 0 if an error happens:

=SUM(IFERROR(QUERY(IMPORTRANGE("mysheet","CR"), 
 "select Col7 
  where Col1 ='"&A4&"' 
    and Col2 ='"&B4&"' 
    and Col13!='Cancelled' 
    and Col13!='Rejected' ", 0)))
player0
  • 124,011
  • 12
  • 67
  • 124