IF statement not working

Comments

4 comments

  • Konsta Danyliuk

    Hello Natasha.
    I hope you are doing fine and staying safe these days.

    The general syntax of the IF function is IF(<Condition>;<Then>;<Else>), thereby you need a third argument in your examples, what to put in case the condition is false.

    For example, the following formulas return D and L respectively in case the condition is true and Z if it is false.

    IF(#_01_USDCs!Warehouse == "F"; "D"; "Z")
    IF(#_01_USDCs!Warehouse == "K"; "L"; "Z")

    If you want the formula to rerun an empty value in case the condition is false, you could use null.

    IF(#_01_USDCs!Warehouse == "F"; "D"; null)
    IF(#_01_USDCs!Warehouse == "K"; "L"; null)

    In case you need to have more than one condition you could use logical operators AND (&&)  and OR (||). The syntax is the following.

    IF(#_01_USDCs!Warehouse == "A" || #_01_USDCs!Warehouse == "B"; "C"; "Z")
    IF(#_01_USDCs!Warehouse == "A" && #_01_USDCs!ID == 254; "C"; "Z")

    I hope this helps. Do not hesitate to let me know if you have any further questions.

    0
    Comment actions Permalink
  • NATASHA BOROVIKOVA

    Hi Konsta,

     

    Thank you for your reply!

     

    If I have more then one IF statement in one formula how to make it all work together. For example, the first IF statement with || just works by itself but if I add more like here below it gives me error. Should I use &&?

     

    IF(#_01_USDCs!Warehouse=="A" || #_01_USDCs!Warehouse=="B";"C"; null)

    IF(#_01_USDCs!Warehouse=="D";"E"; null)

        IF(#_01_USDCs!Warehouse=="F";"G"; null)

     

    0
    Comment actions Permalink
  • Konsta Danyliuk

    Hi Natasha.
    In this case, you could use a set of nested IF functions, just put the subsequent statement instead of the else argument.

    IF(<Condition>;<Then>;IF(<Condition>;<Then>;IF(<Condition>;<Then>;<Else>)))

    For your example it should be something like:

    IF(#_01_USDCs!Warehouse=="A" || #_01_USDCs!Warehouse=="B"; "C"; IF(#_01_USDCs!Warehouse=="D"; "E"; IF(#_01_USDCs!Warehouse=="F"; "G"; null)))

     

        

    1
    Comment actions Permalink
  • NATASHA BOROVIKOVA

    Spasibo Konstantin!!!!

    0
    Comment actions Permalink

Please sign in to leave a comment.