The "IF" function returns "True" instead of an expected number.

Solved
JeanBartassant Posted messages 17 Status Member -  
JeanBartassant Posted messages 17 Status Member -
Hello,

In Libre Office, I wrote a formula using the "If" function, but instead of the expected number, the result displays "True" regardless of the number in cell G (it's a commission that varies according to the price in G).

Here is my formula:
=IF(G<5;0.05;IF(G<10;0.1;IF(G<15;0.2;IF(G>=15;0.4))))

Example: for a price of 14 €, I should get: 0.2 € : instead, I get "True", no matter what the price in G is!

Does anyone have an idea?

Thank you.

1 answer

  1. yclik Posted messages 69 Registration date   Status Member Last intervention   1 608
     
    Hello
    Is the point the decimal marker on your setup?
    see here to modify
    Is G a name given to a cell?
    On my end
    =IF(G2<5,0.05,IF(G2<10,0.1,IF(G2<15,0.2,IF(G2>=15,0.4))))
    works if the cell address is G2 and the decimal is ,

    =IF(G<5,0.05,IF(G<10,0.1,IF(G<15,0.2,IF(G>=15,0.4)))) works with G defined as a name and the decimal is ,
    0
    1. JeanBartassant Posted messages 17 Status Member 1
       
      Thank you for your quick response.

      I tried modifying the decimal, replacing the point in the numeric block with the "," from the keyboard: no change, the cell always displayed "True."

      But your comment about the definition of G gave me the idea to check the "category" of the "number" in the formatting of the cell containing the formula (the one where "True" was displayed). Surprise! It was defined as "logical value" (by default? I hadn't chosen that). So I replaced "logical value" with "number": miracle, the desired result is displayed! The formula was therefore correct; it was the cell formatting that was not.

      Thanks again for your help: I indicate "resolved" for the question.
      0