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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Jos1986
Frequent Visitor

Last Business Day that incorporates Holidays

Hello. We currently use the below formula to calculate last day sales. As you can see it takes into account weekends and skips those days. However, we want to also exclude our company holidays which are known dates. Is there any way I can bring that into this DAX at all or do I have to start with an entirely new measure?
 
Last Day Sales (USD) =
VAR _Today =
    TODAY ()
VAR _latestDate = _Today - 1
VAR _DD =
    SWITCH (
        WEEKDAY ( _Today ),
        2, _Today - 3,
        1, _Today - 2,
        7, _Today - 1,
        _latestDate
    )
RETURN
    CALCULATE ('Sales'[All Sales (USD)], 'Date'[Date] = _DD)
1 ACCEPTED SOLUTION
vicky_
Super User
Super User

If you have known holidays, put those in a table and use the NETWORKDAYS function. so something like

Last Day Sales (USD) = CALCULATE(MAX('date'[Date]), NETWORKDAYS('date'[Date],  TODAY(), 1 , holiday) = 2), 
where holiday is the name of the table containing your company holidays.

View solution in original post

1 REPLY 1
vicky_
Super User
Super User

If you have known holidays, put those in a table and use the NETWORKDAYS function. so something like

Last Day Sales (USD) = CALCULATE(MAX('date'[Date]), NETWORKDAYS('date'[Date],  TODAY(), 1 , holiday) = 2), 
where holiday is the name of the table containing your company holidays.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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