根据 2 个以上的条件编写 "if" 函数
Writing an "if" function based on more than 2 conditions
我正在尝试编写一个公式来执行以下操作:
我在 K37
、N6
、C4
和 C12
中有绝对值。
如果K37
大于N6
,则输出为(N6-C4)*C12
。
如果 K37
小于 N6
但大于 C4
,则输出为 (K37-C4)*C12
。
如果K37
小于C4
,则输出为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"
我正在尝试编写一个公式来执行以下操作:
我在 K37
、N6
、C4
和 C12
中有绝对值。
如果K37
大于N6
,则输出为(N6-C4)*C12
。
如果 K37
小于 N6
但大于 C4
,则输出为 (K37-C4)*C12
。
如果K37
小于C4
,则输出为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"