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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
niirusan
Frequent Visitor

Highlighting Weekends in stacked bar chart

Hi,

 

Can anyone can help?

I have been asked by a client to update the stacked bar chart below such that weekends (and holidays) are highlighted.

 

Bar Chart 2021-08-27.jpg

 

As an approach, I was thinking of creating a calculated column with a DAX formula that returned 1 or TRUE for dates that fall on the weekend and then either applying conditional formatting to the X-Axis column labels and changing the colour of those dates which fall on the weeked, or just having a light grey column which takes up 100% of the width and height of the column.

Unfortunately, it seems that it is neither possible to apply conditional formatting to the axis labels nor have a combined value/percentage bar chart in the basic PowerBI visualisations.

I wondered if anyone has a solution to this problem, or knows of a add-in visualisation that has this functionality

 

Many thanks

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

Hi @niirusan ,

 

You can create the following measure

Measure = 
var _weekend=WEEKDAY(MAX('Table'[Date]),2)
return
IF(_weekend=6||_weekend=7,"red","blue")

Then put the measure into Data colors and set as follows.

14.png

This result is this.

15.png

 

 

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @niirusan ,

 

You can create the following measure

Measure = 
var _weekend=WEEKDAY(MAX('Table'[Date]),2)
return
IF(_weekend=6||_weekend=7,"red","blue")

Then put the measure into Data colors and set as follows.

14.png

This result is this.

15.png

 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Just be careful with your assumptions on what a weekend is. Differs by country.

lbendlin
Super User
Super User

"Unfortunately, it seems that it is neither possible to apply conditional formatting to the axis labels"

 

Not any more! Yay! That feature was recently added.  Update your Power BI Desktop.

 

I would highly recommend you use an external Calendar table that includes your definition of weekend and holiday.  You can also include a color name column right there, and use that for the axis custom formatting.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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