Forum Discussion
Date Difference excluding weekends
Thanks v-yulgu-msft
I created a Date table:
Dim Table=CALENDAR(DATE(2008,1,1),DATE(2018,12,31))
I created a new column with is working day or not
is work day = SWITCH(WEEKDAY([Date]),1,0,7,0,1)
Now I want to create "DateDifference" Column with Createddate & Closeddate (I want to know day diffarence b/w these two dates excluding weekends)
CreatedDate ClosedDate DateDiffarence
Please guide me how to get this done
Something like this:
[Date Diff Measure] =
VAR Created =
MAX ( Table[CreatedDate] )
VAR Closed =
MAX ( Table[ClosedDate] )
RETURN
CALCULATE (
SUM ( 'Dim Table'[is work day] ),
FILTER (
ALL ( 'Dim Table'[DateColumn] ),
'Dim Table'[DateColumn] >= Created
&& 'Dim Table'[DateColumn] <= Closed
)
)- ssvr8 years agoHelper III
Anonymous
some error in DAX
- ssvr8 years agoHelper III
No Data shown in the Output column
- ssvr8 years agoHelper III
Anonymous
Here SLA is measure !
Can you fix this error:
- Anonymous8 years agoNot applicable
Logical expressions that are added to CALCULATE() must be of the format Table[Column] = static expression.
If you want to do a more advanced logical expression, such as the following:
Table[Column] = [Measure]
[Measure] = static expression
[Measure] = [another Measure]
then you need to use FILTER() inside of CALCULATE()
Something like this:
[Count of SLA] = CALCULATE ( DISTINCTCOUNT ( Dates[CreateDt].[Date] ), FILTER ( VALUES(Dates[CreateDt]), [SLA] = "Met SLA" ) )The FILTER() parameter says this:
"Look at the distinct list of dates in the CreateDt column, based on the current filter context (as determined by slicers, etc.) Go through that list line by line and evaluate the [SLA] measure. Only keep those dates where [SLA] = "Met SLA"
Now you have a (likely) smaller list of values from the Dates[CreateDt] column. That is the additional filter that is taken into account when CALCULATE performs the calculation...in this case counting the distinct number of values in the Dates[CreateDt] column.
- ssvr8 years agoHelper III
Anonymous
Thanks ChrisHaas.
Its working great.
Can you fix the DateDiff excluding weekends DAX also