Search code examples
if-statementgoogle-sheetsgoogle-sheets-formulauniquegoogle-query-language

How to avoid this empty row using QUERY() in Google Sheets?


I've tried applying some criteria, but the row is still there.

This first empty row shouldn't be there.

Here is the formula, in case you'd like to help me correct it: =if(I4<>"", { IFERROR(query(Datasets!X3:AU,"select AS, AT, AJ, AR where AS matches date '"&TEXT(DATEVALUE(I4),"yyyy-mm-dd")&"'",0),{"","","",""}); IFERROR(query(Datasets!BC3:BT,"select BC, BD, BS, BQ where BC matches date '"&TEXT(DATEVALUE(I4),"yyyy-mm-dd")&"'",0),{"","","",""}) }, UNIQUE({query(Datasets!X3:AU,"select AS, AT, ' ', SUM(AR) where AS is not null group by AS, AT, ' ' label ' '' ', SUM(AR) ' '",0); query(Datasets!BC3:BT,"select BC, BD, ' ', SUM(BQ) where BC is not null group by BC, BD, ' ' label ' '' ', SUM(BQ) ' '",0) })) enter image description here


Solution

  • try:

    =IF(I4<>"", {IFERROR(QUERY(Datasets!X3:AU, 
     "select AS,AT,AJ,AR 
      where AS matches date '"&TEXT(DATEVALUE(I4), "yyyy-mm-dd")&"'", ), {"","","",""}); 
     IFERROR(QUERY(Datasets!BC3:BT, 
     "select BC,BD,BS,BQ 
      where BC matches date '"&TEXT(DATEVALUE(I4), "yyyy-mm-dd")&"'", ), {"","","",""})}, 
     UNIQUE({QUERY(Datasets!X3:AU,
     "select AS,AT,' ',SUM(AR) 
      where AS is not null 
      group by AS,AT,' '
      label' ''',SUM(AR)''", ); 
     QUERY(Datasets!BC3:BT, 
     "select BC,BD,' ',SUM(BQ) 
      where BC is not null 
      group by BC,BD,' ' 
      label' ''',SUM(BQ)''", )}))