Forum Discussion

HamzaAhmad's avatar
HamzaAhmad
New Member
8 years ago
Solved

Putting more than one condition in IF statement

Hello,

I have this table which is displaying the material count "Balance" and green and red indicators indicate if the material balance is 0 (via a red circular indicator) or more than 0 (via a green circular indicator). I want to include an amber indicator too if the material balance gets to 5. Is this possible in Power BI?

 

Also, when any of the indicators are orange or red, the top indicator should become red or orange. If all is green, it should remain green. Please help me and I greatly appreciate your help.

 

 

Thanks.

  • HamzaAhmad's avatar
    HamzaAhmad
    8 years ago

    I think I am really close. I can get the green and red indicator but it is not turning amber if the materials become less than 5 but greater than 0, instead it turns green.

     

    This is my formula:

     

    Close = IF(CONTAINS(Material,Material[Balance],0),"https://image.ibb.co/mVYPcm/rsz_1redindicator.png",IF(CONTAINS(Material,Material[Balance],5,Material[Balance],4,Material[Balance],3,Material[Balance],2,Material[Balance],1),"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png","https://image.ibb.co/kLLRq6/rsz_greenindicator.png"))

    Please advise what am I missing here.

     

    I solved the first problem by using SWITCH. Formula below:

     

    Indicator = SWITCH([Balance],0,"https://image.ibb.co/mVYPcm/rsz_1redindicator.png",5,"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png",4,"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png",3,"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png",2,"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png",1,"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png","https://image.ibb.co/kLLRq6/rsz_greenindicator.png")

2 Replies

  • Solved the second problem by this formula

     

    Column = IF(CONTAINS(Material,Material[Balance],0),"https://image.ibb.co/mVYPcm/rsz_1redindicator.png","https://image.ibb.co/kLLRq6/rsz_greenindicator.png")

     

    However, the first problem remains, how to put more than one condition in the IF statement. Something like ELSE IF in PHP.

     

    Thanks for your help

    • HamzaAhmad's avatar
      HamzaAhmad
      New Member

      I think I am really close. I can get the green and red indicator but it is not turning amber if the materials become less than 5 but greater than 0, instead it turns green.

       

      This is my formula:

       

      Close = IF(CONTAINS(Material,Material[Balance],0),"https://image.ibb.co/mVYPcm/rsz_1redindicator.png",IF(CONTAINS(Material,Material[Balance],5,Material[Balance],4,Material[Balance],3,Material[Balance],2,Material[Balance],1),"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png","https://image.ibb.co/kLLRq6/rsz_greenindicator.png"))

      Please advise what am I missing here.

       

      I solved the first problem by using SWITCH. Formula below:

       

      Indicator = SWITCH([Balance],0,"https://image.ibb.co/mVYPcm/rsz_1redindicator.png",5,"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png",4,"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png",3,"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png",2,"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png",1,"https://image.ibb.co/c0LRq6/rsz_orangeindicator.png","https://image.ibb.co/kLLRq6/rsz_greenindicator.png")