Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

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 

 

Aziza_0-1645637991082.png

 

 

 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

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

dif1.pngdif2.png

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

2 REPLIES 2
v-luwang-msft
Community Support
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.

vluwangmsft_1-1646039517429.png

 

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

PhilipTreacy
Super User
Super User

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

dif1.pngdif2.png

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.