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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jbolivar
Frequent Visitor

Calculating number of days between two dates without holydays and weekend

Hello everyone. I ask you for help with this problem that I have. I have reviewed many post but I do not give with the solution. I have been able to do it in Excel but not in Power BI.Tabla SLA_Excel.JPG

 

 

RESTAR 2 DATES WITHOUT WEEKENDS:
I need to subtract 2 dates that are in the same table. But the result should be without the weekends.

For example: Creation Date is 08/16/2017 and the end date is 08/22/2017. The result of a simple subtraction would be 6; But what I need is that I do not take the weekends. The result should be 4.

Tabla SLA_PBI.JPG

 

HOLIDAYS:

Perhaps in another column or in the same one of the case of paragraph above, if in that period of the 2 dates exists a holiday also must subtract it.
Example: Between 04/07/2017 and 07/07/2017 we have 05/07/2017 which is Holiday. The result should be: 2 (3 days minus 1 holiday = 2).

The ideas that come to mind are:
1.- The total result is in a column or
2.- A column with the number of holidays between those dates, another column with the number of Weekends between those dates and then the final column of results

 

The image below is an example of the expected results

ejemplo.JPG

 

Thank you!

 

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Jihwan_Kim_0-1719114396236.png

 

 

expected result measure: =
VAR _list =
    CALENDAR ( MIN ( data[date_start] ), MAX ( data[date_end] ) )
VAR _holidaylist =
    { DATE ( 2017, 7, 5 ) }
VAR _weekendlist =
    SUMMARIZE (
        FILTER (
            ADDCOLUMNS ( _list, "dayname", FORMAT ( [Date], "dddd" ) ),
            [dayname] IN { "Saturday", "Sunday" }
        ),
        [Date]
    )
RETURN
    IF (
        HASONEVALUE ( data[customer_id] ),
        COUNTROWS (
            FILTER ( _list, NOT ( [Date] IN _holidaylist && [Date] IN _weekendlist ) )
        ) - 1
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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.