Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

PowerBI measure IF statement

Hi, 

I am trying to write an IF statement where I would like my arrows to go up and down accordin to the value and change its colour at the same time.

I am doing the change of colour by nesting two IF statement as I don't have the option to use conditional formating in the measure I have created using UNICHAR. I know something is wrong but I can't figure out. 

Please any guidance would be really appreciated. 

Thank you, 

Aziza 

 

 

 

 

  • Hi Anonymous 

     

    Download PBIX example with solution

     

    I'm not sure if you are using columns or measures in your IF but it doesn't matter I guess for the purposes of my example.

    What you need to do is create a measure for the value,

    _DEBT Diffs = IF (SUM('Sheet2'[Debt Recovered]) > SUM('Sheet2'[Debt Value]), UNICHAR(9660), UNICHAR(9650))

     

    and create another measure for the color.

    _DEBT Diffs Color = IF (SUM('Sheet2'[Debt Recovered]) > SUM('Sheet2'[Debt Value]), "#FF0000", "#66ff33")

     

    Then you can set conditional formatting like so

     

    Regards

     

    Phil

2 Replies

  • v-luwang-msft's avatar
    v-luwang-msft
    Community Support

    Hi Anonymous ,

    Your error is due to the wrong use of if.

    IF(<logical_test>, <value_if_true>[, <value_if_false>])

    or

    IF(<logical_test1>,if(<logical_test2>, <value_if_true2>[, <value_if_false2>]),<value_if_false1>)

    In addition colormeasure is used as a formatting condition, rather than acting directly on measures or columns.

    You could use  Unichar(128315) get red down arrow,but no unicode for green arrow up ,and we can use (9650) grey arrow and switch to green under column formating, select the measure Arrows changue font color to  00B200  and activate all options except Header.

     

    To learn more details ,you could refer the following articles:

    https://community.powerbi.com/t5/Community-Blog/Power-BI-Desktop-DAX-Using-Unicode-Arrows-as-Measures-in-a-Table/ba-p/190725#comments 

     

     

    Did I answer your question? Mark my post as a solution!


    Best Regards

    Lucien

  • Hi Anonymous 

     

    Download PBIX example with solution

     

    I'm not sure if you are using columns or measures in your IF but it doesn't matter I guess for the purposes of my example.

    What you need to do is create a measure for the value,

    _DEBT Diffs = IF (SUM('Sheet2'[Debt Recovered]) > SUM('Sheet2'[Debt Value]), UNICHAR(9660), UNICHAR(9650))

     

    and create another measure for the color.

    _DEBT Diffs Color = IF (SUM('Sheet2'[Debt Recovered]) > SUM('Sheet2'[Debt Value]), "#FF0000", "#66ff33")

     

    Then you can set conditional formatting like so

     

    Regards

     

    Phil