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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
BW617
New Member

Need help after calculating date difference excluding weekends.

So I have a calculation comparing number of working days between two dates. I have a date table and the calculation works just fine.

 

CycleTimexWeekends = CALCULATE(SUM(CalendarTable[WorkingDay]),DATESBETWEEN(CalendarTable[Date],Data[Date_Of_Receipt_Formula],Data[Original_Date_of_Response]))

 

The problem is since it's a sum of the working day count on the date table, if the date of receipt and date of response are the same it counts as 1, where it should be a 0.

 

 

 

 

I figured a new calculated column to take that column and -1 would work. and it does in instances where the date of receipt and response are the same

 

Date_Of_Receipt_FormulaOriginal_Date_of_ResponseCycleTimexWeekendsCycleTime_Corrected
11/23/201811/23/201810

 

However it will throw off all the other dates:

 

Date_Of_Receipt_FormulaOriginal_Date_of_ResponseCycleTimexWeekendsCycleTime_Corrected
11/23/201811/23/201810
11/22/201811/26/201832
11/23/201811/26/201821
11/24/201811/26/201810
11/26/201811/26/201810
11/22/201811/27/201843
11/23/201811/27/201832

 

does anyone know a way where I can account for the same date of receipt and response, to have it be 0 but keep all the other logic?

 

 

 

thank you!

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Perhaps:

 

CycleTimexWeekendsCorrected = 
VAR __cycleTime = CALCULATE(SUM(CalendarTable[WorkingDay]),DATESBETWEEN(CalendarTable[Date],Data[Date_Of_Receipt_Formula],Data[Original_Date_of_Response]))
RETURN
IF(Data[Date_Of_Receipt_Formula] = Data[Original_Date_of_Response]),0,__cycleTime)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
ThaddeusB
Helper I
Helper I

You could just use an If statement:

 

IF ([Date_Of_Receipt_Formula]=[Original_Date_of_Response], 0, [CycleTimexWeekends])

 

But are you sure that is actually what you want?  All of your example span a weekend, but what about weekday-weekday?  Do you want 11/26-11/27 to be counted as 2 days (as your forumula will do)?  

ahhh, in all of this I forgot about that simple solution, that would work just fine. I'm measuring response to customers, so if the date is the same I would want it to equal 0. thanks for the help!

Greg_Deckler
Community Champion
Community Champion

Perhaps:

 

CycleTimexWeekendsCorrected = 
VAR __cycleTime = CALCULATE(SUM(CalendarTable[WorkingDay]),DATESBETWEEN(CalendarTable[Date],Data[Date_Of_Receipt_Formula],Data[Original_Date_of_Response]))
RETURN
IF(Data[Date_Of_Receipt_Formula] = Data[Original_Date_of_Response]),0,__cycleTime)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.