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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Dunner2020
Post Prodigy
Post Prodigy

Difference between date and time columns (excluding public holidays)

Hi there,

 

I have two date and time columns (let say 'Start date time' & 'End date time') and they have values like '1/01/1900 12:00:00 AM'. I also got a table that contains a list of public holidays. Holidays contain the date of holiday without a year. For example, the Christmas holiday value would be December 25th. 

I want to create a measure that calculates the difference between 'Start date time' and 'End date time' in Days and exclude the public holidays. I am not sure how to exclude the public holidays from the list, specially when public holiday does not have year. Any help would be really appreciated. 

1 ACCEPTED SOLUTION
edhans
Super User
Super User

You have to have a date table to do this properly. If your date table has an IsHoliday column then you simply count the rows in the date table between your start/end dates that are not holidays. Then this measure would work:

 

 

Non-Holiday Day Count = 
VAR varStartDate =
    MAX( 'Date Ranges'[Start Date] )
VAR varEndDate =
    MAX( 'Date Ranges'[End Date] )
VAR varDayCount =
    CALCULATE(
        COUNTROWS( Dates ),
        FILTER(
            ALL( Dates ),
            Dates[Date] >= varStartDate
                && Dates[Date] <= varEndDate
                && Dates[IsHoliday]
                    = FALSE()
        )
    )
RETURN
    varDayCount

 

 

See my PBIX file here for how the tables work. You can see them in the Transform Data section before they are loaded to DAX.

 

Creating a Dynamic Date Table in Power Query

Slight edit: If you also want to exclude weekends, use this. My Day of Week column has 0-6 for every day, where 0 is Sunday, 6 is Saturday, so this only includes days 1-5.

Non-Holiday Day Count = 
VAR varStartDate =
    MAX( 'Date Ranges'[Start Date] )
VAR varEndDate =
    MAX( 'Date Ranges'[End Date] )
VAR varDayCount =
    CALCULATE(
        COUNTROWS( Dates ),
        FILTER(
            ALL( Dates ),
            Dates[Date] >= varStartDate
                && Dates[Date] <= varEndDate
                && Dates[IsHoliday]
                    = FALSE()
                && Dates[Day of Week] IN GENERATESERIES(1,5)
        )
    )
RETURN
    varDayCount


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

1 REPLY 1
edhans
Super User
Super User

You have to have a date table to do this properly. If your date table has an IsHoliday column then you simply count the rows in the date table between your start/end dates that are not holidays. Then this measure would work:

 

 

Non-Holiday Day Count = 
VAR varStartDate =
    MAX( 'Date Ranges'[Start Date] )
VAR varEndDate =
    MAX( 'Date Ranges'[End Date] )
VAR varDayCount =
    CALCULATE(
        COUNTROWS( Dates ),
        FILTER(
            ALL( Dates ),
            Dates[Date] >= varStartDate
                && Dates[Date] <= varEndDate
                && Dates[IsHoliday]
                    = FALSE()
        )
    )
RETURN
    varDayCount

 

 

See my PBIX file here for how the tables work. You can see them in the Transform Data section before they are loaded to DAX.

 

Creating a Dynamic Date Table in Power Query

Slight edit: If you also want to exclude weekends, use this. My Day of Week column has 0-6 for every day, where 0 is Sunday, 6 is Saturday, so this only includes days 1-5.

Non-Holiday Day Count = 
VAR varStartDate =
    MAX( 'Date Ranges'[Start Date] )
VAR varEndDate =
    MAX( 'Date Ranges'[End Date] )
VAR varDayCount =
    CALCULATE(
        COUNTROWS( Dates ),
        FILTER(
            ALL( Dates ),
            Dates[Date] >= varStartDate
                && Dates[Date] <= varEndDate
                && Dates[IsHoliday]
                    = FALSE()
                && Dates[Day of Week] IN GENERATESERIES(1,5)
        )
    )
RETURN
    varDayCount


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors