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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

change background color of cells of matrix visual based on slicer selection in power bi

I have  a range slicer of percentage from which I can select the values between 0-5%, 6-10% and >10%

Please note that I dont want these slicers to be used for data filtering instaed, I want them to use for coloring in Matrix.

Ex- If I select the range from the slicer 0-5%, all the rows in the matrix, should change the color.

4 REPLIES 4
v-weiyan1-msft
Community Support
Community Support

Hi @Anonymous ,

 

@Daniel29195 Thank you, for your helpful and quick response.
You can also consider the following method.
I am not sure how your semantic model looks like.
Based on your description, here is the dummy data I created.
Table:

vweiyan1msft_0-1709608016814.png

SlicerTable:

vweiyan1msft_1-1709608032744.png

The fields in the matrix are as follows.

vweiyan1msft_2-1709608042751.png

Please try code as below to create a measure.

MEASURE = 
SELECTEDVALUE ( Slicer[Percentage] )

Then select the your matrix, and in the Visualizations pane, under Visual > Cell elements > Background color, click "fx" icon, and do the following.

vweiyan1msft_3-1709608076517.png

vweiyan1msft_4-1709608085121.png

The field of the slicer is from SlicerTable. When you select "0-5%" in the slicer, Result is as below.

vweiyan1msft_5-1709608110794.png

Is this the result you expect?
Please correct me if I misunderstood your needs.


Best Regards,
Yulia Yan


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

Anonymous
Not applicable

@v-weiyan1-msft 

Thanks for your response Yulia.

However it does not meet my expectations. My expectations is below-

If you can see from the slicer in left, we have seleted two ranges and according color has been filled in. Green for 0-5% and Amber for 6-10%

Nikhil_567_0-1709641494320.png

 

Daniel29195
Super User
Super User

@Anonymous 

create a measure, like this : 

measure = 

switch(

true(), 

condition 1 , "red", 

condition 2 , "blue" ,

....

 

 

in the matrix, go to cell elemnts, background color, and choose field value -->  select the measure you created above .

 

 

 

hope this helps. 

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

Anonymous
Not applicable

It is filtering the data which is not the actual requirement.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors