nested IF without repeating the condition to be tested
wrote:
is there a nice elegant way to avoid repeating the same
test condition when nesting multiple IF?
I mean, my condition is a long formula which must be equal
to something. 4 different results are possible. So 3 nested
IF. At the moment I write again my long formula to be tested
in each IF
[....]
IF(condition=1;true;(if(condition=2;true;(if(condi tion=3;true;....
and so on
If you want to return the same "true" result in all cases, you can write:
=IF(OR(expression={1,2,3,4}),trueResult,falseResul t)
Note: That formula can be entered normally by pressing just Enter. It does
__not__ need to be array-entered by pressing ctrl+shift+Enter.
More generally, if you are sure that "condition" (expression) will equal
only 1 through 4, you can write:
=CHOOSE(expression,result1,result2,result3,result4 )
If "expression" might have other results, but you are content to default to
"result1" or "result4" in that case, then perhaps you need:
=CHOOSE(MAX(1,MIN(4,ROUND(expression,0))),result1, result2,result3,result4)
|