Search code examples
if-statementgoogle-sheetsfilterarray-formulasgoogle-query-language

ArrayFormula Only Populating When Not Empty


I have the following formula =ARRAY_CONSTRAIN(ARRAYFORMULA(IF(ARTIST_FILTER_MENU="", TRUE, IF(ARTIST_FILTER_MENU=Data!B2:B, TRUE, false))), COUNTA(Data!B2:B), 1) that will populate TRUE/FALSE values depending on whether data matches a selection in a dropdown menu. And if the dropdown menu is empty, the Boolean result defaults to TRUE.

When the dropdown menu is not empty, the formula works fine, but when it is empty, only the first row is populated.

No dropdown option selected (expected output):

T T T T T

No dropdown option selected (actual output):

T

After struggling with it for a bit, I figured out it had to do with the line ARTIST_FILTER_MENU="" where I haven't used the A#:A format that is usually required for the ArrayFormula function. I found a temporary solution by checking against a random empty cell range instead of "", or is there a better way that I should go about this?


Solution

  • try:

    =ARRAY_CONSTRAIN(ARRAYFORMULA(
     IF(ARTIST_FILTER_MENU="", TRUE&IFERROR(Data!B2:B/0), 
     IF(ARTIST_FILTER_MENU=Data!B2:B, TRUE&"", FALSE&""))), COUNTA(Data!B2:B), 1)
    

    enter image description here

    =QUERY({TRACK_NAME_HELPER_RNG, RELEASES_DATA_RNG, RELEASES_HELPER_RNG}, Helpers!$A$11&
     " WHERE Col1 IS NOT NULL 
         AND Col"&Helpers!$B$3&" = 'TRUE' 
         AND Col"&Helpers!$B$5&" = 'TRUE'", 1)
    

    enter image description here