Reputation: 895
I am trying call another measure from datediff function, but I am getting below error.
Below is what I have done.
My SelectTime Measure definition is as below.
Also I have an Intermediate table called Interval, Though which I will be selecting the TimePeriod by putting it in a slicer.
Can someone please explain me what am I missing here, TIA.
Upvotes: 0
Views: 483
Reputation: 8148
As far as I know, interval in DateDiff must be a constant, and can not be a variable. It's a limitation of DAX language which I hope Microsoft will improve at some point.
For now, you can use a different approach.
SelectTime = SELECTEDVALUE(Interval[TimePeriod])
Then:
MyDateDiff =
VAR Start_Date = DATE(1984,11,01)
VAR End_Date = DATE(1089, 08, 08)
RETURN
SWITCH(
[SelectTime],
"Day", DATEDIFF(Start_Date, End_Date, DAY),
"Month", DATEDIFF(Start_Date, End_Date, MONTH),
"Week", DATEDIFF(Start_Date, End_Date, WEEK),
DATEDIFF(Start_Date, End_Date, YEAR)
)
Upvotes: 2