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

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.

Reply
mrmrb
Frequent Visitor

Clustered Bar Chart - Bar Colour Depends on Position of Bar

I have a slicer of dates where a user can choose 1 or more dates (multiple selection). The expected scenario is for the user to choose 2 dates, where the intention is to show values on a clustered column chart comparing values as at the 2 selected dates for each of a number of scenarios. I have configured the chart such that the chart legend shows the 2 selected dates, and the bar colours are chosen (eg date 1 bar colour is grey and date 2 bar colour is blue for all scenarios).

 

All good and well. The problem comes when the date selection is changed by the user. I need my bars to all stay the same colour as originally chosen ie whichever 2 dates the user selects, the earlier date bars must always be grey, and the later date bars must always be blue. In many searches and trials so far, I have not been able to achieve this - the bars always change colour as the dates are changed to different dates because the bar colour is associated with the date and not with the position of the bar in the chart. I would like to know if anyone has either achieved this before or has some ideas on how to achieve this.

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@mrmrb 

 

Drag [Date] to Axis instead of Legend and try Color formatting by field value from the Data colors card in the formatting pane.

 

Measure =
IF (
    SELECTEDVALUE ( 'Table'[Date] )
        = CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED ( 'Table'[Date] ) ),
    "#808080",
    "#0000FF"
)

 

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@mrmrb 

 

Drag [Date] to Axis instead of Legend and try Color formatting by field value from the Data colors card in the formatting pane.

 

Measure =
IF (
    SELECTEDVALUE ( 'Table'[Date] )
        = CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED ( 'Table'[Date] ) ),
    "#808080",
    "#0000FF"
)

 

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you very much for your suggestion. This achieves what I need in terms of the colour consistency. Unfortunately moving the date to the Axis instead of the Legend means that the bars no longer group together neatly as before, and also the axis labels become crowded...

             Target ViewTarget View                                Achieved so farAchieved so far

There isn't an option to apply the conditional colour formatting when the date is in the legend, so I may not be able to get any closer to the target view for now. But this is definitely a step in the right direction. My thanks, once again.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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