Google Sheets – Skip ARRAYFORMULA If Result Is Blank

formulasgoogle sheetsgoogle-formsgoogle-sheets-arrayformulagoogle-sheets-query

I have an array formula that looks like this:

=ArrayFormula(IF(COUNTIF(B2:B, QUERY('Form Responses'!B2:G, "select G where B != ''"))=0, IFERROR(QUERY('Form Responses'!B2:G, "select B, G where B != ''"), "")))

It retrieves data from a different sheet that's connected to Google Forms.
With the first IF and COUNTIF I try to check whether the G column from the form response sheet is already present in the B column in my current sheet.
If that is not the case, I query column B and G.

However, if the value is present already, I don't want to query it, but I also don't want an empty line, which is now happening because of the "" as the third argument for the IF statement.

Is there a way in which I can only query if not a duplicate, without adding an empty line otherwise?

Best Answer

  • the "" is part of IFERROR not IF therefore try:

    =QUERY(ARRAYFORMULA(IF(COUNTIF(B2:B, 
     IFERROR(QUERY('Form Responses'!B2:G, "select G   where B !=''", 0)))=0, 
     IFERROR(QUERY('Form Responses'!B2:G, "select B,G where B !=''", 0)), )), 
     "where Col1 is not null", 0)