Home > Software design >  Label giving error when using formulas within query statement/parameter in QUERY in Google Sheets
Label giving error when using formulas within query statement/parameter in QUERY in Google Sheets

Time:01-18

I have made much of what I wanted to work, but there's just one last thing.

=QUERY(ALL!$A$4:$AB, "SELECT A, B, D, C, I, G, O, U, Y, U/I, C/U WHERE A is not null "
&IF(OR(SUFIAN!$F$15="", SUFIAN!$F$16=""), "", " AND C >= "&SUFIAN!F15&" AND C <= "&SUFIAN!F16&"")
&IF(OR(SUFIAN!$H$15="", SUFIAN!$H$16=""), "", " AND G >= "&SUFIAN!H15&" AND G <= "&SUFIAN!H16&"")
&IF(OR(SUFIAN!$G$15="", SUFIAN!$G$16=""), "", " AND I >= "&SUFIAN!G15&" AND I <= "&SUFIAN!G16&"")
&IF(OR(SUFIAN!$I$15="", SUFIAN!$I$16=""), "", " AND O >= "&SUFIAN!I15&" AND O <= "&SUFIAN!I16&"")
&IF(OR(SUFIAN!$J$15="", SUFIAN!$J$16=""), "", " AND U >= "&SUFIAN!J15&" AND U <= "&SUFIAN!J16&"")
&IF(OR(SUFIAN!$K$15="", SUFIAN!$K$16=""), "", " AND Y >= "&SUFIAN!K15&" AND Y <= "&SUFIAN!K16&"")
&IF(OR(SUFIAN!$L$15="", SUFIAN!$L$16=""), "", " AND AA >= "&SUFIAN!L15&" AND AA <= "&SUFIAN!L16&"")
&IF(OR(SUFIAN!$M$15="", SUFIAN!$M$16=""), "", " AND AB >= "&SUFIAN!M15&" AND AB <= "&SUFIAN!M16&""),1)

All of this is working, but when I try to Label the column U/I, and C/U, the query mostly gives me the 'Formula parse error', or sometimes the 'expecting ... instead' error.

I am making a mistake somewhere, probably with the quotations. Let's say I want to name U/I as Orders Per Session, and C/U should be Sales Per Session. Any idea how I can achieve that?

SAMPLE SHEET

CodePudding user response:

use:

=QUERY(ALL!$A$4:$Z, "SELECT A, B, D, C, I, G, O, U, Y, U/I, C/U WHERE A is not null "
&IF(OR(SUFIAN!$D$1="", SUFIAN!$D$2=""), "", " AND C >= "&SUFIAN!D1&" AND C <= "&SUFIAN!D2&"")
&IF(OR(SUFIAN!$F$1="", SUFIAN!$F$2=""), "", " AND G >= "&SUFIAN!F1&" AND G <= "&SUFIAN!F2&"")
&IF(OR(SUFIAN!$E$1="", SUFIAN!$E$2=""), "", " AND I >= "&SUFIAN!E1&" AND I <= "&SUFIAN!E2&"")
&IF(OR(SUFIAN!$G$1="", SUFIAN!$G$2=""), "", " AND O >= "&SUFIAN!G1&" AND O <= "&SUFIAN!G2&"")
&IF(OR(SUFIAN!$H$1="", SUFIAN!$H$2=""), "", " AND U >= "&SUFIAN!H1&" AND U <= "&SUFIAN!H2&"")
&IF(OR(SUFIAN!$I$1="", SUFIAN!$I$2=""), "", " AND Y >= "&SUFIAN!I1&" AND Y <= "&SUFIAN!I2&"")
&IF(OR(SUFIAN!$J$1="", SUFIAN!$J$2=""), "", " AND AA >= "&SUFIAN!J1&" AND AA <= "&SUFIAN!J2&"")
&IF(OR(SUFIAN!$K$1="", SUFIAN!$K$2=""), "", " AND AB >= "&SUFIAN!K1&" AND AB <= "&SUFIAN!K2&"")&
 "label U/I'xx',C/U'yy'",1)
  • Related