Excel formula - min, max

Stefan Iliev

x=...

y=...

5*(x-y)=

if "x" and "y" are with different signs (-/+ or +/-) the formula should be like that,

but if "x" and "y" are with same signs (-/- or +/+) in the brackets should stay only one value with his sign - the absolute value of (x and y).

How should it look like?

Máté Juhász

If I understand your question correctly, you can use this formula:

=5*IF(SIGN(A2)=SIGN(B2),IF(SIGN(A2)=1,MAX(A2,B2),MIN(A2,B2)),A2-B2)

How it works:

  • IF(SIGN(A2)=SIGN(B2) - if signs are the same
    • IF(SIGN(A2)=1 - if numbers are positive
    • MAX(A2,B2) - returns bigger number
    • MIN(A2,B2) - returns smaller number (bigger absolute value for negative numbers mean smaller number)
  • else returns A2-B2

enter image description here

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章