Search code examples
google-sheetsconditional-statementsarray-formulas

How do I add a condition to an array lookup?


=ArrayFormula(LOOKUP(2,1/($E$2:E="foo"),$F$2:F)),"")

=ArrayFormula(LOOKUP(2,1/($E$2:E="foo",$a$2:a="bar"),$F$2:$F)),"")

The first snippet is finding the last entry in column F where Column E="foo"

The second snippet I am trying to add another condition that column A="bar" but its throwing errors.


Solution

  • To simulate an AND, you have to multiply the conditions.

    =ARRAYFORMULA(LOOKUP(2,1/((E2:E="foo")*(A2:A="bar")),F2:F))
    

    Or you can simply use FILTER combined with CHOOSEROWS.

    =CHOOSEROWS(FILTER(F2:F,A2:A="bar",E2:E="foo"),-1)