cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Change Table Color based on associated slicer selection

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Highlighted
Helper III
Helper III

Re: Change Table Color based on associated slicer selection

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

Highlighted
Super User II
Super User II

Re: Change Table Color based on associated slicer selection

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Highlighted
Helper II
Helper II

Re: Change Table Color based on associated slicer selection

@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

Highlighted
Super User II
Super User II

Re: Change Table Color based on associated slicer selection

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors