cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gdxy
Helper I
Helper I

Bar display according to slicer

Hi,

 

Currently, I am working on displaying data with a bar chart and a slicer, I would like to have the bar highlighted when being selected instead of just showing the selected item, how can I have the effect like fig 1 instead of fig 2, thx!

Fig1: 

gdxy_0-1665202009851.png

Fig2:

gdxy_1-1665202082050.png

 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @gdxy ,

 

if the axis of the bar chart and the content of the slicer are coming from the same table this will not work.

Create a model that looks like this:

image.png


The table slicer is used to provide the content for the slicer.

 

Create a measure like this:

 

vizAid HighlightColumn = 
var SelectedSlicerItems = VALUES( 'Slicer'[item] )
return
IF(
    SELECTEDVALUE( 'Dimension'[item] ) in SelectedSlicerItems
    , "red"
    , "blue"
)

 

Use the measure to add conditional formatting to the columns:

Use the table Dimension to populate the axis, then you can create something like below: 

image.png

 

Hopefully, this provides what you are looking for.

 

Regards,
Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

5 REPLIES 5
TomMartens
Super User
Super User

Hey @gdxy ,

 

if the axis of the bar chart and the content of the slicer are coming from the same table this will not work.

Create a model that looks like this:

image.png


The table slicer is used to provide the content for the slicer.

 

Create a measure like this:

 

vizAid HighlightColumn = 
var SelectedSlicerItems = VALUES( 'Slicer'[item] )
return
IF(
    SELECTEDVALUE( 'Dimension'[item] ) in SelectedSlicerItems
    , "red"
    , "blue"
)

 

Use the measure to add conditional formatting to the columns:

Use the table Dimension to populate the axis, then you can create something like below: 

image.png

 

Hopefully, this provides what you are looking for.

 

Regards,
Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
VijayP
Super User
Super User

@gdxy 

In normal course of action it is not possible. 

workaround , Create a slicer and table and chart

remove the interaction between chart and Slicer

create interaction between chart and table as highligh

select slicer which shows single value in table and select the value in table which creates the effect required by you!

But that I donot think that is going to be an automated !




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


lukiz84
Solution Sage
Solution Sage

I can't imagine any way that would be possible... sorry

Avantika-Thakur
Responsive Resident
Responsive Resident

Hi @gdxy ,

1) You can remove the interaction of the slicer with the bar chart so that it doesn't filter out the selected element in bar graph.

2) Then  create a measure for highlighting colour of the selected bar - 
Measure = IF(Level = SelectedValue(Level), "Dark Colour hex code for highlighting","Light Colour hex code for highlighting")
3) Add this colour returning measure to the "Fx" option of the bar chart setting of Bar colours.

 

Hope this helps!

Please accept the solution if this answers your query.

 

Thanks,

Avantika

And what would the Level in IF(Level = ...) be in a measure? That's not possible.

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.