首页 > 解决方案 > Multiple conditions in an array

问题描述

I'm having this problem where, when referencing more than a condition in a range, it "doesn't run", the cell is just blank. The expected process for the first condition, for example, was to check if, in the same row, A2:A="1" and B2:B="2", if both of these conditions where true, in the same row, it would return sucess1.

I'm using Google Sheets, but I think that this might also apply to Excel.

Code

=ARRAYFORMULA(IFS(
    AND(A2:A="1", B2:B="2"), "sucess1", 
    AND(A2:A="3", B2:B="4"), "sucess2",
TRUE,))

标签: arraysif-statementgoogle-sheetsgoogle-sheets-formulaarray-formulas

解决方案


arrayformula 不支持ANDand OR。所以:

=ARRAYFORMULA(IF((A2:A=1)*(B2:B=2), "sucess1", 
              IF((A2:A=3)*(B2:B=4), "sucess2", )))

推荐阅读