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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Previous Workday

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...

WorkDay = IF(OR('Calendar'[WeekDay]=1,'Calendar'[WeekDay]=7),0,IF(ISBLANK('Calendar'[Holiday]),1,0))
 
 
1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

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


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Perfect, thanks!

OwenAuger
Super User
Super User

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


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.