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
Marico
Helper II
Helper II

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/...

View solution in original post

4 REPLIES 4
Marico
Helper II
Helper II

@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

 

@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/...

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.