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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply

Column to Calculate the number of workdays between two date columns

Hello All,

 

I'm trying to calculate the number of Non-Weekend days between two dates.  Basically what I've done is create a date table 'CountWorkingDays' that contains all dates from 1/1/2016 to Today and a column that numerically indicates the day of the week (Sun-Sat, 1-7).

 

The calculated column I'm using is called '2to3'

The Date columns I'm comparing are 'DateSentToVRMGroup' and 'DateApprovedProcessed'

The formula I'm trying to use is:

2to3 = if(or(ISBLANK([DateSentToVRMGroup]),ISBLANK([DateApprovedProcessed])),9999999,if([DateSentToVRMGroup]>[DateApprovedProcessed],0,CALCULATE(COUNT(CountWorkingDays[DayofWeek]),FILTER(CountWorkingDays,CountWorkingDays[Date]>[DateSentToVRMGroup] && CountWorkingDays[Date]<[DateApprovedProcessed] && CountWorkingDays[DayofWeek]<>1 && CountWorkingDays[DayofWeek]<>7))))

 

The formula isn't generating an error but all of the rows are coming up blank.  Is there something I'm doing wrong?

 

Thanks in advance for the help!

1 ACCEPTED SOLUTION
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @HansTheEnforcer

 

You could try adding the following calculated column.  Just replace 'Table2' with your table name.

 

No date table requried for this one 🙂

 

Count of Weekdays = 
VAR StartDate = DATE(2016,1,1)
VAR EndDate = TODAY()
VAR WeekDayTable = SELECTCOLUMNS(FILTER(ADDCOLUMNS(CALENDAR(StartDate,EndDate),"WeekDay",IF(WEEKDAY([Date])in {1,7},0,1)),[WeekDay]=1),"Week Day",[Date])
VAR Result = COUNTROWS(CALCULATETABLE(filter(CROSSJOIN(WeekDayTable,Table2),'Table2'[DateSentToVRMGroup]<[Week Day] && [DateApprovedProcessed]>[Week Day])))
RETURN Result

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @HansTheEnforcer

 

You could try adding the following calculated column.  Just replace 'Table2' with your table name.

 

No date table requried for this one 🙂

 

Count of Weekdays = 
VAR StartDate = DATE(2016,1,1)
VAR EndDate = TODAY()
VAR WeekDayTable = SELECTCOLUMNS(FILTER(ADDCOLUMNS(CALENDAR(StartDate,EndDate),"WeekDay",IF(WEEKDAY([Date])in {1,7},0,1)),[WeekDay]=1),"Week Day",[Date])
VAR Result = COUNTROWS(CALCULATETABLE(filter(CROSSJOIN(WeekDayTable,Table2),'Table2'[DateSentToVRMGroup]<[Week Day] && [DateApprovedProcessed]>[Week Day])))
RETURN Result

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thanks, it worked great!!!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.