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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cottrera
Post Prodigy
Post Prodigy

Calculate the working days (excluding weekends and holidays) between Date logged and Today's Date

Hi I need to calculate the working days (exlcuding weekends and holidays) between the Date logged and Todays date (See jobs raised able below) I have a calendar table (see calendar table below) which contains a column to show weekends and a column to show holidays .  I also have a the following calculationTodays Date = TODAY()

 

My recent post (See link) was to Calculate working days between dates - excluding holiday for raised and completed dates. I can only asume the request above is similar, however I am fairly new to DAX and am unable to edit it.

 

thank you 

 

Jobs raised table 

Job referenceDate Logged
541722623/01/2019
551290105/03/2019
552736412/03/2019
553360015/03/2019
553491315/03/2019
554448321/03/2019
556139601/04/2019
556726104/04/2019
557025605/04/2019
557033905/04/2019
557371305/04/2019
557391105/04/2019
557467005/04/2019
557654305/04/2019
557662605/04/2019
557663405/04/2019
557677505/04/2019
557723605/04/2019
557739305/04/2019
557880405/04/2019
557911705/04/2019
558742510/04/2019
559084012/04/2019
560139018/04/2019
560309923/04/2019
560322123/04/2019

 

PKDateis_weekendis_holiday
03/04/201700
04/04/201700
05/04/201700
06/04/201700
07/04/201700
08/04/201710
09/04/201710
10/04/201700
11/04/201700
12/04/201700
13/04/201700
14/04/201701
15/04/201710
16/04/201710
17/04/201701
18/04/201700
19/04/201700
20/04/201700
21/04/201700
22/04/201710
23/04/201710
24/04/201700
25/04/201700
26/04/201700
27/04/201700
1 ACCEPTED SOLUTION
CheenuSing
Community Champion
Community Champion

Hi @cottrera 

 

Please try the following

 

1. Create a measure    

                                 NoOfDays = SUMX(LoggedData,DATEDIFF(LoggedData[DateLogged],today(),DAY) )

     

    This computes the number of lapsed days between logged date and today.

 

2.  Create a measure

                  NoOfWeekends = 
                                        Var CurLoggedDate = SELECTEDVALUE(LoggedData[DateLogged])
                                           Return
                                              CALCULATE(COUNT(DateTable[WeekEnd]),

                                                       FIlter(DateTable,DateTable [Date]>=CurLoggedDate &&
                                                                                                                            DateTable[Date] <= Today() && 
                                                                                                          DateTable[WeekEnd] = 1) )

         This will check the DateTable for number of weekends between logged date and today.

         So we get the number of weekends.

 

3.  Create a measure

                  NoOfHolidays= 
                                        Var CurLoggedDate = SELECTEDVALUE(LoggedData[DateLogged])
                                           Return
                                              CALCULATE(COUNT(DateTable[Holiday]),

                                                       FIlter(DateTable,DateTable [Date]>=CurLoggedDate &&
                                                                                                                            DateTable[Date] <= Today() && 
                                                                                                          DateTable[Holiday] = 1) )

         This will check the DateTable for number of Holidays between logged date and today.

         So we get the number of Holidays.

 

4. Finally create a measure

             NetWorkingDays = [NoOfDays] -[NoOfWeekends] -[NoOfHolidays]

 

 

Based on your sample data I changed the date table year to 2019. With the above measures the table output is

 

 

NWD.JPG

 

Cheers

 

CheenuSing

 

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
CheenuSing
Community Champion
Community Champion

Hi @cottrera 

 

Please try the following

 

1. Create a measure    

                                 NoOfDays = SUMX(LoggedData,DATEDIFF(LoggedData[DateLogged],today(),DAY) )

     

    This computes the number of lapsed days between logged date and today.

 

2.  Create a measure

                  NoOfWeekends = 
                                        Var CurLoggedDate = SELECTEDVALUE(LoggedData[DateLogged])
                                           Return
                                              CALCULATE(COUNT(DateTable[WeekEnd]),

                                                       FIlter(DateTable,DateTable [Date]>=CurLoggedDate &&
                                                                                                                            DateTable[Date] <= Today() && 
                                                                                                          DateTable[WeekEnd] = 1) )

         This will check the DateTable for number of weekends between logged date and today.

         So we get the number of weekends.

 

3.  Create a measure

                  NoOfHolidays= 
                                        Var CurLoggedDate = SELECTEDVALUE(LoggedData[DateLogged])
                                           Return
                                              CALCULATE(COUNT(DateTable[Holiday]),

                                                       FIlter(DateTable,DateTable [Date]>=CurLoggedDate &&
                                                                                                                            DateTable[Date] <= Today() && 
                                                                                                          DateTable[Holiday] = 1) )

         This will check the DateTable for number of Holidays between logged date and today.

         So we get the number of Holidays.

 

4. Finally create a measure

             NetWorkingDays = [NoOfDays] -[NoOfWeekends] -[NoOfHolidays]

 

 

Based on your sample data I changed the date table year to 2019. With the above measures the table output is

 

 

NWD.JPG

 

Cheers

 

CheenuSing

 

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Thank you works fine.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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