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! Learn more

Reply
Anonymous
Not applicable

Need to calculate Networkdays from datetime stamp

Hi Friends,

I need ur help to calculate the network days between two DateTime stamp. I have tried all solution which already provided in this forum but unfortunately, I'm unable to get the below output. Please advise me on this.

 

Opened date # 22/01/2021 18:15:33

Closed Date # 25/01/2021 18:04:44

Networkdays Output in decimal # 0.99

1 ACCEPTED SOLUTION
Payeras_BI
Solution Sage
Solution Sage

Hi @Anonymous ,

Sure, find attached the PBIX file.

Payeras_BI_0-1616079429364.png

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

View solution in original post

7 REPLIES 7
Payeras_BI
Solution Sage
Solution Sage

Hi @Anonymous ,

Sure, find attached the PBIX file.

Payeras_BI_0-1616079429364.png

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
Payeras_BI
Solution Sage
Solution Sage

Hi @Anonymous ,

Ok. You can use Bill Szysz's Function fxSOWH (Sum of working hours) for your purposes.
More details here

Link to the original Excel file

As you tell me, for now, don't care about the Start and End of working hours I set it as below:

Payeras_BI_0-1615999686065.png

Then just changed the Sum of working hours format from Hour to General and got what you are looking for:

Payeras_BI_1-1615999921608.png

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
Anonymous
Not applicable

Thank you for this solution. Can you please guide me on how to implement this in the Power BI Desktop?

 

Payeras_BI
Solution Sage
Solution Sage

Hi @Anonymous ,

Given both "Opened Date" and "Closed Date" always fall on Working days and you have a list of Holidays like this:

Payeras_BI_1-1615924621164.png

Payeras_BI_2-1615924679825.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLSNzDUNzIwMlQwtLAyNLUyNlbSUTIyRRY1MLEyMVGKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Opened date" = _t, #"Closed date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Opened date", type datetime}, {"Closed date", type datetime}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each 
        let 
        ListOfDates = List.Dates(Date.From([Opened date]),Number.From(Date.From([Closed date])-Date.From([Opened date])),#duration(1,0,0,0)),
        ListOfHolidays = List.Intersect({Holidays,ListOfDates}),
        ListOfWeekends = List.Select(ListOfDates, each Date.DayOfWeek(_,1) > 4 ),
        ListOfDatestoSubstract = List.Distinct(List.Combine({ListOfHolidays,ListOfWeekends})),
        DaystoSubstract = List.Count(ListOfDatestoSubstract)
        in
        Duration.TotalDays([Closed date]-[Opened date]) - DaystoSubstract)
in
    #"Added Custom"

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
Anonymous
Not applicable

Sakthi_Kumar_0-1615964794810.png

 

Thank you for the solution. However, I have received the above error message. Also, at some time Opened date/Closed date will be a Weekend date

Hi @Anonymous ,

Re the error received make sure you convert your Holiday table to a list before using it in your code.

Payeras_BI_0-1615981434921.png

Re "Sometimes Opened date/Closed date will be a Weekend date", provide one of these examples and the expected output.

Do you also plan to take into account the Working hours?

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
Anonymous
Not applicable

Hi,

As requested, Please find the below examples were ticket opened & Closed on Weekend days.

Capture.JPG

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 Kudoed Authors