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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
KG1
Resolver I
Resolver I

Working Days

Hi 

 

I have a date table linked to a completion date in my data table.

 

I need to be able to calculate the number of working days between the onsite date and completion date in the data table

 

I have already created a column in my date table which identifies a working day as 1 and a non working day as 0

 

I would like to create a calculated column to show the number of working days. If the onsite date and completion date are on the same day then the output would need to show 1.

Onsite_DateCompletion DateWorking days
10-Sep-2114-Sep-213
10-Aug-2111-Aug-212
10-Aug-2111-Aug-212
10-Aug-2111-Aug-212
10-Aug-2111-Aug-212
10-Aug-2111-Aug-212
10-Aug-2111-Aug-212
10-Aug-2111-Aug-212
17-Aug-2123-Aug-215
10-Aug-2111-Aug-212
11-Aug-2123-Aug-219
11-Aug-2123-Aug-219
11-Aug-2123-Aug-219

 

Thank you in advance

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@KG1 , Try a new column like

 

business Day = COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(Table[Onsite_Date],Table[Completion Date]),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1))

 

How to calculate Business Days/ Workdays, with or without date table: https://youtu.be/Qv4wT8_P-AA

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

4 REPLIES 4
KG1
Resolver I
Resolver I

Hi - there were anomilies in there data where some the of the end dates were before the start dates. I created 2 new conditonal columns to flip the dates around and the DAX worked perfectly - thank you very much

amitchandak
Super User
Super User

@KG1 , Try a new column like

 

business Day = COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(Table[Onsite_Date],Table[Completion Date]),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1))

 

How to calculate Business Days/ Workdays, with or without date table: https://youtu.be/Qv4wT8_P-AA

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi Apologies but I get the following error message

 

The start date in Calendar function can not be later than the end date.

 

 

@KG1 , Make sure the first date is a smaller one

 

 

business Day = if(Table[Onsite_Date] < Table[Completion Date] , COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(Table[Onsite_Date],Table[Completion Date]),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1)),
COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(Table[Completion Date],Table[Onsite_Date]),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1))

)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.