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

Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.

Reply
Marico
Helper III
Helper III

Conditionally formatting % values in a table based on slicer selection

I have a requirement where the background color of the numbers needs to be changed based on the slicer selection. The sales column is of the "Percentage" data type.

 

- If the Region is selected as East, the sales is less than 50% then "RED" else "GREEN"

- If the Region is selected as West, the sales are less than 60% then "RED" else "GREEN"

 

CountryPopulationSales
Sweden          119,99750%
Germany            16,77770%
USA            10,00030%
India            34,07840%
Netherlands            46,76790%
Japan            78,99965%

 

Slicer values:

Region:

- East

- West

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Marico , a Color measure

 

Switch( true() ,

selectedvalue(Table[Region]) = "East" && [Sales] <.5, "Red" ,

selectedvalue(Table[Region]) = "East" && [Sales] >=.5, "Green" ,

selectedvalue(Table[Region]) = "West" && [Sales] <.6, "Red" ,

selectedvalue(Table[Region]) = "West" && [Sales] >=.6, "Green" )

 

 

Use this measure in conditional formatting using field value option

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Marico
Helper III
Helper III

@amitchandak Kudos! This works well. 

However, I have 5 such fields like Sales where the above type of conditional formatting needs to be applied in the table.

 

1. Would I need to create 5 different measures for each field like the one above?

2. Will combining in the single measure and using it in conditional formatting (field value) would also work?

3. What will happen when user selects "Select All" option instead of either "East" or "West"?

 

Appreciate your support!

@Marico , Assume another measure is margin and you want to color margin based on margin %, then I would advise creating a new measure.

 

if every thing is based on sales , then just use switch , if etc and create one measure

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Sure, thanks

 

What will happen when user selects "Select All" option instead of either "East" or "West" - Will it show the values based on threshold of East or West in that case?

 

Client has a requirement wherein they want to have the "Select All" option enabled in the slicer along with "East" and "West".

amitchandak
Super User
Super User

@Marico , a Color measure

 

Switch( true() ,

selectedvalue(Table[Region]) = "East" && [Sales] <.5, "Red" ,

selectedvalue(Table[Region]) = "East" && [Sales] >=.5, "Green" ,

selectedvalue(Table[Region]) = "West" && [Sales] <.6, "Red" ,

selectedvalue(Table[Region]) = "West" && [Sales] >=.6, "Green" )

 

 

Use this measure in conditional formatting using field value option

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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