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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
H3nning
Helper V
Helper V

Mark second workday in calendar table

Hi, Im struggling with a little challenge and hope some is able to solve it!

 

I have a calendar table with two columns:

DateIs Workday
2024-01-010
2024-01-021
2024-01-031
2024-01-041
......

 

I need to mark the second workday depending on the Is Workday column (not depending on day of week). So in case of January 2024 this would be the 3rd of January, because 1st is marked as non workday. I need to do this for the entire table for every month each second workday. It can be a 0/1 coding for 1 being the second workday.

 

Thanks in advance!

2 ACCEPTED SOLUTIONS
Kedar_Pande
Resident Rockstar
Resident Rockstar

@H3nning 

Calculated Column

SecondWorkday = 
VAR CurrentMonth = MONTH('Calendar'[Date])
VAR CurrentYear = YEAR('Calendar'[Date])
VAR WorkdayRank =
RANKX(
FILTER(
'Calendar',
'Calendar'[Is Workday] = 1 &&
MONTH('Calendar'[Date]) = CurrentMonth &&
YEAR('Calendar'[Date]) = CurrentYear
),
'Calendar'[Date],
,
ASC
)
RETURN
IF(WorkdayRank = 2, 1, 0)

This approach dynamically calculates the second workday for every month in your table.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

 

View solution in original post

It works if I add a filter for Is Workday:

SecondWorkday = 
VAR CurrentMonth = MONTH('Calendar'[Date])
VAR CurrentYear = YEAR('Calendar'[Date])
VAR WorkdayRank =
RANKX(
FILTER(
'Calendar',
'Calendar'[Is Workday] = 1 &&
MONTH('Calendar'[Date]) = CurrentMonth &&
YEAR('Calendar'[Date]) = CurrentYear
),
'Calendar'[Date],
,
ASC
)
RETURN
IF(WorkdayRank = 2 && 'Calendar'[Is Workday] = 1, 1, 0)

View solution in original post

3 REPLIES 3
Kedar_Pande
Resident Rockstar
Resident Rockstar

@H3nning 

Calculated Column

SecondWorkday = 
VAR CurrentMonth = MONTH('Calendar'[Date])
VAR CurrentYear = YEAR('Calendar'[Date])
VAR WorkdayRank =
RANKX(
FILTER(
'Calendar',
'Calendar'[Is Workday] = 1 &&
MONTH('Calendar'[Date]) = CurrentMonth &&
YEAR('Calendar'[Date]) = CurrentYear
),
'Calendar'[Date],
,
ASC
)
RETURN
IF(WorkdayRank = 2, 1, 0)

This approach dynamically calculates the second workday for every month in your table.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

 

It works if I add a filter for Is Workday:

SecondWorkday = 
VAR CurrentMonth = MONTH('Calendar'[Date])
VAR CurrentYear = YEAR('Calendar'[Date])
VAR WorkdayRank =
RANKX(
FILTER(
'Calendar',
'Calendar'[Is Workday] = 1 &&
MONTH('Calendar'[Date]) = CurrentMonth &&
YEAR('Calendar'[Date]) = CurrentYear
),
'Calendar'[Date],
,
ASC
)
RETURN
IF(WorkdayRank = 2 && 'Calendar'[Is Workday] = 1, 1, 0)

Hi thanks for your reply. It does not produce the right result though.

In March 2024 it results in:

DateIs WorkdayResult
2024-03-0110
2024-03-0201
2024-03-0301
2024-03-0411
...  

Helpful resources

Announcements
Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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