Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Nestet if else

Hello to everybody, I don't get it. I don't know why. Maybe to long working days. 

 

It is a easy problem but I am lost. I would like to check the results for the column "Bedarfsmenge" to column "Bedarfsmenge.4". 

If column Bedarfsmenge is null then take value of Bedarsfmenge.1, if this column is empty take Bedarfsmenge.2 and so on. 

 

This is my code:

 

"Benutzerdefiniert", each if [Bedarfsmenge] = null then [Bedarfsmenge.1] else if [Bedarfsmenge.1] = null then [Bedarfsmenge.2] else if [Bedarfsmenge.2] = null then [Bedarfsmenge.3] else if [Bedarfsmenge.3] = null then [Bedarfsmenge.4] else [Bedarfsmenge])

 

But result is not as wished the value of column "Bedarsmenge.2". It is null. What is wrong? 

 

5 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello Alien, I didn't get it. I'm lost with this information, sorry for that. What I have to change in my formula?

      • AlienSx's avatar
        AlienSx
        Super User

        Anonymous , the code in your message <> code in your picture. Replace zeros (0) with null in the formula in PQ (your picture) and see how it works. You are expecting that null is equal to 0. It doesn't.  

  • Nathaniel_C's avatar
    Nathaniel_C
    Community Champion

    Hi Anonymous ,
    As I look at your picture, the data type has not been selected in the columns.
    First I would fix that.
    Next if the value = "null" use that in your formula.  If the value = 0 then use that in your formula.

    Finally it is easier to write a SWITCH(TRUE()).
    So it might look like this:
    SWITCH(TRUE(),
    Column1<>0,
    Column2<>0,
    Column3<>0
    )
    This formula uses whichever value is true that it comes to first.  So, if Column1 <> 0 is true, it will use that value and if not it will continue checking subsequent values.

    Hope this helps.

    Let me know if you have any questions.

    If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos ๐Ÿ‘are nice too.
    Nathaniel