Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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
Solved! Go to Solution.
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
Select format by 'Field value' and then select your newly created measure.
You'll then end up with something like this:
You can find more info here: docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting
Hope it helps.
Best regards,
Martyn
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
Select format by 'Field value' and then select your newly created measure.
You'll then end up with something like this:
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
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
73 | |
58 | |
36 | |
32 |
User | Count |
---|---|
90 | |
60 | |
60 | |
49 | |
45 |