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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Calculate time between two dates in working days only - select rows (DAX)

Hi !

I'm calculating a time btw 2 dates and I'm trying to keep only working days.

To do so, I used a table Calendar w/ a column of dates and a column displaying a 1 for dates of working days and 0 for non working days (week-end, etc).

I came up with this DAX formula :

ORDER_REQUESTED2 =
VAR StartDate = SELECTEDVALUE(ShipDetails[ORDERED_DATE])
VAR EndDate = SELECTEDVALUE(ShipDetails[REQUEST_DATE])
RETURN
CALCULATE(
SUMX('Calendar',1-'Calendar'[Working Day]),
'Calendar'[Date] > StartDate,
'Calendar'[Date] <= EndDate
)
But it doesn't work, an error message is displayed, saying that the syntax of the CALCULATE function is incorrect. I don't understand why.
Do you have any idea of what I could do to fix it ?
Thank you very much for your help.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you.

In fact my formula is working, I'm new to Power BI so I thought that I used the CALCULATE function in a wrong way but in fact I just made a typo.

Sorry that I bothered you for this and thank you for your answer. 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous ,

Refer if this file can help you. Check 2nd Page

https://www.dropbox.com/s/y47ah38sr157l7t/Order_delivery_date_diff.pbix?dl=0

Anonymous
Not applicable

Thank you.

In fact my formula is working, I'm new to Power BI so I thought that I used the CALCULATE function in a wrong way but in fact I just made a typo.

Sorry that I bothered you for this and thank you for your answer. 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.