Skip to content
Advertisement

How can I refer to 2 differents dataset into a gsheet query formula?

I’m trying to get a formula to match 2 different data set in google sheets. I did the following but I keep getting “parse error”

iferror(if(len($D10)> 0,
      query({'Sheet1'!$A$2:$T;'Sheet2'!$A$2:$BK}
            "select {'Sheet2'!$A$2:$BK}.B where {'Sheet2'!$A$2:$BK}.A contains 'condition2'
                and {'Sheet2'!$A$2:$BK}.D contains'"&$D$4&"
                and {'Sheet1'!$A$2:$T}.N >= date '"&text(($A$4), "YYYY-MM-DD")&"'
                and {'Sheet1'!$A$2:$T}.N <= date '"&text(($B$4), "YYYY-MM-DD")&"'",0),""),"")

With D10 is the cell that I’ll look up the match for.

Let me know if you have any tips and thanks!

Advertisement

Answer

The syntax for QUERY is QUERY(data, query, [headers])

In your case, you forgot the , between the data and the query.

It should be ...query({'Sheet1'!$A$2:$T;'Sheet2'!$A$2:$BK}, "select {'Sheet2'!$A$2:$BK}.B where...

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement