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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Daniel_B
Helper II
Helper II

Change Table Color based on associated slicer selection

Hi All

 

I'm trying to make the colour of a table change based on the associated slicer selection

 

Would I need to create a measure for all of the available selections (in this instance I have 4, positive, negative, mixed and neutral) and a table with free-text which fall under one of those 4 categories

 

For example:

 

Free Text              Sentiment

Blah Blah Blah      Neutral

 

Would I need to create a measure where free-text row = NEUTRAL, add that to the table then set up a conditional format to show if slicer selection = NEUTRAL then table colour = BLUE

 

If that isn't the case, any links/ideas that might guide me on this one


Thanks


Dan_B

 

1 ACCEPTED SOLUTION
MartynRamsden
Solution Sage
Solution Sage

Hi @Daniel_B 


Create a measure similar to below (you'll need to replace the table name with your actual table name):

 

Sentiment Colour = 
VAR SelSentiment = SELECTEDVALUE ( 'Table'[Sentiment] )
VAR Result =
SWITCH (
    TRUE(),
    SelSentiment = "Positive", "Green",
    SelSentiment = "Negative", "Red",
    SelSentiment = "Neutral", "Gray",
    SelSentiment = "Mixed", "Orange"
)
RETURN Result

 

Then, head to the formatting pane of your table visualisation and expand Conditional Formatting.

Select the relevant field and enable 'Background color'.

Click Advanced controls

 

Capture.JPG

 

Select format by 'Field value' and then select your newly created measure.

 

Capture1.JPG

 

You'll then end up with something like this:

 

Capture2.JPG

 

 

 

 

 

You can find more info here: docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting 

 

Hope it helps.


Best regards,

Martyn

View solution in original post

4 REPLIES 4
MartynRamsden
Solution Sage
Solution Sage

Hi @Daniel_B 


Create a measure similar to below (you'll need to replace the table name with your actual table name):

 

Sentiment Colour = 
VAR SelSentiment = SELECTEDVALUE ( 'Table'[Sentiment] )
VAR Result =
SWITCH (
    TRUE(),
    SelSentiment = "Positive", "Green",
    SelSentiment = "Negative", "Red",
    SelSentiment = "Neutral", "Gray",
    SelSentiment = "Mixed", "Orange"
)
RETURN Result

 

Then, head to the formatting pane of your table visualisation and expand Conditional Formatting.

Select the relevant field and enable 'Background color'.

Click Advanced controls

 

Capture.JPG

 

Select format by 'Field value' and then select your newly created measure.

 

Capture1.JPG

 

You'll then end up with something like this:

 

Capture2.JPG

 

 

 

 

 

You can find more info here: docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting 

 

Hope it helps.


Best regards,

Martyn

@MartynRamsden , thank you so much for that - works perfectly (colours are a bit bolder than I'd like but I can work on that 🙂 )

 

Very Much appreciated

Hi @Daniel_B 

 

No problem!

 

You can replace the names of the colours in the DAX expression with the hex code of any colour you prefer.
There's an example of this towards the bottom of the article I linked to.


Best regards,
Martyn

Anonymous
Not applicable

I think this can be accomplished with conditional formatting. Maybe make a calculated field that has a number (1,2,3,4) based on your slicer selection with an "IF" statement?

 

IF Sentiment = Neutral THEN 0 etc.

 

Then make a conditional format that colors the values red, orange, green, etc based on the calculated field.

 

https://community.powerbi.com/t5/Community-Blog/Conditional-Formatting-in-Power-BI-Tables/ba-p/42799...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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