Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
So I have a calendar table and was able to create a calculated column that tags each workday with a 1. How would I create a calculated column to tag a day as the previous workday?
Here is the dax for my workday column...
Solved! Go to Solution.
Hi @Anonymous
Just confirming, are you wanting a 0/1 flag that is equal to 1 for the workday immediately before the current date when the table is refreshed/processed (i.e. TODAY() )?
If so, something like this should work:
Previous WorkDay =
VAR ReferenceDate = TODAY ()
VAR MaxWorkDayBeforeReferenceDate =
CALCULATE (
MAX ( 'Calendar'[Date] ),
ALL ( 'Calendar' ),
'Calendar'[Date] < ReferenceDate,
'Calendar'[WorkDay] = 1
)
RETURN
INT ( 'Calendar'[Date] = MaxWorkDayBeforeReferenceDate )
If you instead want a column that returns the date of the workday preceding the current row's date, something like this should work:
Previous WorkDay Date =
VAR ReferenceDate = 'Calendar'[Date]
RETURN
CALCULATE (
MAX ( 'Calendar'[Date] ),
ALL ( 'Calendar' ),
'Calendar'[Date] < ReferenceDate,
'Calendar'[WorkDay] = 1
)
Regards,
Owen
Perfect, thanks!
Hi @Anonymous
Just confirming, are you wanting a 0/1 flag that is equal to 1 for the workday immediately before the current date when the table is refreshed/processed (i.e. TODAY() )?
If so, something like this should work:
Previous WorkDay =
VAR ReferenceDate = TODAY ()
VAR MaxWorkDayBeforeReferenceDate =
CALCULATE (
MAX ( 'Calendar'[Date] ),
ALL ( 'Calendar' ),
'Calendar'[Date] < ReferenceDate,
'Calendar'[WorkDay] = 1
)
RETURN
INT ( 'Calendar'[Date] = MaxWorkDayBeforeReferenceDate )
If you instead want a column that returns the date of the workday preceding the current row's date, something like this should work:
Previous WorkDay Date =
VAR ReferenceDate = 'Calendar'[Date]
RETURN
CALCULATE (
MAX ( 'Calendar'[Date] ),
ALL ( 'Calendar' ),
'Calendar'[Date] < ReferenceDate,
'Calendar'[WorkDay] = 1
)
Regards,
Owen
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 24 | |
| 17 | |
| 10 | |
| 7 | |
| 6 |