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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
YongZhao
Regular Visitor

How to do complex conditional formatting

Hello Guys, I have face an issues based on conditional formatting. Hope you can help

What I plan to do know is, when I click on "believe" (shown as 1 below), the highest number in the table should show th darkest red, and smallest number should show lightest red

 

On the other side, when i click on "not believe" (shown as 2 below), the highest number in the table should show darkest green, else, lightest green

YongZhao_0-1664172241311.png

 

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @YongZhao ,

 

Gradients in conditional formatting cannot currently change color gradients dynamically.

As a workaround, You could create a measure, define color intervals, and apply it to conditional formatting.

For example, here I define three intervals.

Measure = 
var _max=MAXX(FILTER(ALLSELECTED('Table'),[Type]=MAX('Table'[Type])),[Value])
var _value=SUM('Table'[Value])
var _red=SWITCH(TRUE(),_value>0&&_value<=_max/3,"#FDC2C2",_value>_max/3&&_value<=_max/3*2,"#FD6E6E",_value>_max/3*2&&_value<=_max,"#FD0000")
var _green=SWITCH(TRUE(),_value>0&&_value<=_max/3,"#CCFECC",_value>_max/3&&_value<=_max/3*2,"#86F986",_value>_max/3*2&&_value<=_max,"#00FF00")
return SWITCH(SELECTEDVALUE('Table (2)'[Believe or Not believe]),"Believe",_red,"Not Believe",_green)

Click the "fx" under the cell elements.

vstephenmsft_0-1664245237422.png

Select Based on the measure I created.

vstephenmsft_1-1664245279566.png

vstephenmsft_2-1664245337388.png

vstephenmsft_3-1664245356221.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

1 REPLY 1
v-stephen-msft
Community Support
Community Support

Hi @YongZhao ,

 

Gradients in conditional formatting cannot currently change color gradients dynamically.

As a workaround, You could create a measure, define color intervals, and apply it to conditional formatting.

For example, here I define three intervals.

Measure = 
var _max=MAXX(FILTER(ALLSELECTED('Table'),[Type]=MAX('Table'[Type])),[Value])
var _value=SUM('Table'[Value])
var _red=SWITCH(TRUE(),_value>0&&_value<=_max/3,"#FDC2C2",_value>_max/3&&_value<=_max/3*2,"#FD6E6E",_value>_max/3*2&&_value<=_max,"#FD0000")
var _green=SWITCH(TRUE(),_value>0&&_value<=_max/3,"#CCFECC",_value>_max/3&&_value<=_max/3*2,"#86F986",_value>_max/3*2&&_value<=_max,"#00FF00")
return SWITCH(SELECTEDVALUE('Table (2)'[Believe or Not believe]),"Believe",_red,"Not Believe",_green)

Click the "fx" under the cell elements.

vstephenmsft_0-1664245237422.png

Select Based on the measure I created.

vstephenmsft_1-1664245279566.png

vstephenmsft_2-1664245337388.png

vstephenmsft_3-1664245356221.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors