我需要一些帮助!
我有 4 个条件,并且根据条件有 2 个以上不同的结果,因此很难使用 IF/AND/OR 语句。所有数据都是日期。a2 是参考日期:
Condition 1 b2<>"", c2<>"" - true = (b2-a2) , false - see other conditions
Condition 2 b2<>", c2="" - true = (b2-a2) , false - see other conditions
Condition 3 b2="", c2="" - true = (today()-a2), false, see other conditions
Condition 4 b2="", c2<>"" - true = "", false, see other conditions
答案1
正如您所写,它应该是这样的:
=IF(AND(B2<>"",C2<>""),B2-A2,IF(AND(B2<>"",C2=""),B2-A2,IF(AND(B2="",C2=""),TODAY()-A2,IF(AND(B2="",C2<>""),"","How did you get here?"))))
但是,前两个条件忽略 C2,而后两个条件仅当 B2 为空时才会检查,因此您可以将其缩短为:
=IF(B2<>"",B2-A2,IF(C2="",TODAY()-A2,""))