Forum Discussion
H3nning
Helper V
1 year agoMark 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: Date Is Workday 2024-01-01 0 2024-01-02 1 2024-01-03 1 2...
- 1 year ago
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 - 1 year ago
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)
Kedar_Pande
Super User
1 year agoCalculated 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
- H3nning1 year ago
Helper V
Hi thanks for your reply. It does not produce the right result though.
In March 2024 it results in:
Date Is Workday Result 2024-03-01 1 0 2024-03-02 0 1 2024-03-03 0 1 2024-03-04 1 1 ... - H3nning1 year ago
Helper V
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)