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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

If Date is a Monday then return previous Friday and Exclude Holidays

Hello, I am looking for some help on a calculation I am doing. I just need help calculating the previous day excluding weekends and holidays. I have a date table setup with the holidays and weekends already mapped and I was using a calculation to get the previous day excluding weekends, but I do not know how to also configure it to skip holidays. Any help would be appreciated. Here is the calc I am currently using from another post.Previous Day.JPG

 

 

_PreviousDay = 
VAR _Date =
    dimDate[Date]
VAR _latestDate = _Date - 1
VAR _DD =
    SWITCH (
        WEEKDAY ( _Date ),
        2, _Date - 3,
        1, _Date - 2,
        7, _Date - 1,
        _latestDate
    )
RETURN
   _DD

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You posted this in the Power Query board. Do you want the result in Power Query or in DAX?

 

_PreviousDay = 
VAR _Date =
    [Date]
RETURN MAXX(FILTER(dimDate,[Date]<_Date && [Holiday Or Weekend]=FALSE()),[Date])

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

You posted this in the Power Query board. Do you want the result in Power Query or in DAX?

 

_PreviousDay = 
VAR _Date =
    [Date]
RETURN MAXX(FILTER(dimDate,[Date]<_Date && [Holiday Or Weekend]=FALSE()),[Date])

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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

Top Solution Authors