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
jmhoskinson
Helper I
Helper I

Dynamic Holiday Calendar

I'm trying to create a calendar that automatically marks US holidays (without hard coding the dates in or having a holiday lookup table). I've created the date table with the CALENDARAUTO function, and I have no problem marking the static holidays (New Years, Christmas, Independence Day).

I can't get the changing holidays to work (Thanksgiving, Labor Day, etc.). The big problem is counting occurences of a day of the week in the month (Thanksgiving is the 4th Thursday of November). I know some kind of running total function should do the trick, but I cannot get it to work as a measure or calculated column.

Any help would be most appreciated!

1 ACCEPTED SOLUTION

hi @jmhoskinson 

Just try this logic to create a column

Holiday = var num=IF('Date'[Month]=11&&'Date'[Weekday]=4,RANKX(FILTER('Date','Date'[YearMonth]=EARLIER('Date'[YearMonth])&&'Date'[Weekday]=4),'Date'[Date],,ASC,Skip)) return
IF('Date'[Month]=11&&num=4,"thanksgiving day")

Result:

7.JPG

Of cource, you need use WEEKDAY Function and other data function to define Weekday/YearMonth in advance.

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
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

5 REPLIES 5
pthapa
Resolver I
Resolver I

How can I achieve the holiday column for Memorial Day and Labor Day in Dax.

Thank you in advance.

PT.

Anonymous
Not applicable

Hi @jmhoskinson ,

We can't acheive this without having holiday lookup table.
You could vote for idea like this
https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/39090790-holidays-in-calendar-tab...

Best Regards,

Mail2inba4

 

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

So is there no way to count what Thursday of the month a date is in DAX? That's really the core of my question.

hi @jmhoskinson 

Just try this logic to create a column

Holiday = var num=IF('Date'[Month]=11&&'Date'[Weekday]=4,RANKX(FILTER('Date','Date'[YearMonth]=EARLIER('Date'[YearMonth])&&'Date'[Weekday]=4),'Date'[Date],,ASC,Skip)) return
IF('Date'[Month]=11&&num=4,"thanksgiving day")

Result:

7.JPG

Of cource, you need use WEEKDAY Function and other data function to define Weekday/YearMonth in advance.

 

and here is sample pbix file, please try it.

 

Regards,

Lin

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

This works wonderfully! I also repurposed your code for the other changing US holidays. Thanks!

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.