Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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.
  • Anonymous's avatar
    Anonymous
    6 years ago

    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. 

2 Replies