Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
97 | |
77 | |
63 | |
55 |
User | Count |
---|---|
143 | |
109 | |
89 | |
84 | |
66 |