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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
iDataDrew
Advocate IV
Advocate IV

Number of days between two dates, but only counting work/business days...

Sample data: https://www.dropbox.com/sh/lzgqonrufze6mql/AABDGjIHOvu7iraqXeqKTmA9a?dl=0

 

We have a "PromiseDate" which is when we tell the customer it will be ready. The product needs to be passed quality control (DatePassedQC) at least one work day prior to the PromiseDate. If the DatePassedQC is on or after the PromiseDate, then the order is late by the number of workdays between the two dates.

 

So in short, I need to calculate the number of workdays between the PromiseDate and the DatePassedQC date, but also keep in mind that sometimes the DatePassedQC date will be before the PromiseDate and other times it will be after the PromiseDate.  You should be able to access the sample files, which represent the date tables I'm working with.

 

Thank you for your help.

1 ACCEPTED SOLUTION
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @iDataDrew

 

I created the following Calculated Table using your data. If it's close, it may only need a slight tweek around the < and > operators on the FILTER

 

New QCTable = SUMMARIZE(
            FILTER(
			 CROSSJOIN(QCTable,'DateTable'),
             [Date] >= [PromiseDate] 
             && [Date] <= [DatePassQC] 
             && [IsWorkDay] = true()
             ),
             [PromiseDate],
             QCTable[DatePassQC],
             "Count of Week Days",
             COUNTA('DateTable'[Date])
             )

Which gave me this

 

weekdays.png


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

Proud to be a Datanaut!

View solution in original post

4 REPLIES 4
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @iDataDrew

 

I created the following Calculated Table using your data. If it's close, it may only need a slight tweek around the < and > operators on the FILTER

 

New QCTable = SUMMARIZE(
            FILTER(
			 CROSSJOIN(QCTable,'DateTable'),
             [Date] >= [PromiseDate] 
             && [Date] <= [DatePassQC] 
             && [IsWorkDay] = true()
             ),
             [PromiseDate],
             QCTable[DatePassQC],
             "Count of Week Days",
             COUNTA('DateTable'[Date])
             )

Which gave me this

 

weekdays.png


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

Proud to be a Datanaut!

@v-huizhn-msft and @Phil_Seamark I figured it out.  @Phil_Seamark's solution ended up working.  For some reason, it didn't work when I had a relationship between the QC table and the DimDate table.  When I deleted that relationship, then the New QCTable worked.  Any ideas on why that would be?  Either way, thank you for the solution!

Thank you for the quick response @Phil_Seamark.  See screenshot below.  I used the same calculated table, but did not get the same result.  Have any ideas on why that might be?  Thank you.

 

NewQCTable.PNG

Hi @iDataDrew,

After tested, you it return the same result like @Phil_Seamark. Please confirm you have created a new table(by click "New Table" under Modeling on home page) rether than a calculated column?

1.PNG

Best Regards,
Angelia

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.