写一个" if"功能基于2个以上的条件

时间:2017-10-12 02:23:13

标签: excel formulas

我正在尝试编写公式来执行以下操作:

我在K37N6C4C12中拥有绝对值。

如果K37大于N6,则输出为(N6-C4)*C12

如果K37小于N6但大于C4,则输出为(K37-C4)*C12

如果K37小于C4,则输出为0

1 个答案:

答案 0 :(得分:0)

做什么

=IF(K37>N6, (N6-C4)*C12, IF(AND(K37<N6, K37>C4), (K37-C4)*C12, IF(K37<C4, 0, "NOT TREATED CASE")))

相应的伪代码可能是

if K37>N6 then
    return (N6-C4)*C12
else (if K37<=N6)
    if K37<N6 and K37>C4 then
        return (K37-C4)*C12
    else (if not (K37<N6 and K37>C4) )
        if K37<C4 then
            return 0
        else
            return "not treated case in which one
                    possibly has, e.g. K37=C4 or K37=N6"
相关问题