Forum Discussion
Anonymous
3 years agoNot applicable
DAX measure error date is incompatible with int.
Hi all, Im trying to configure the functionality where based on a selection of a month in the filter, the visual shows the previous 12 months going back from the selected month. I wrote a DAX meas...
Anonymous
3 years agoNot applicable
That returns the date time of the selected date in the filter (based on 'dim_Date'[EOM Date])
johnt75
Super User
3 years agoTry
12 Months back =
VAR CurrentDateTime =
SELECTEDVALUE ( 'dim_Date'[EOM Date], MAX ( 'dim_Date'[EOM Date] ) )
VAR CurrentDate =
DATE ( YEAR ( CurrentDateTime ), MONTH ( CurrentDateTime ), DAY ( CurrentDateTime ) )
VAR Result =
CALCULATE (
SUM ( 'fact'[column] ),
DATESINPERIOD ( 'Date'[Date], CurrentDate, -12, MONTH )
)
RETURN
Result
- Anonymous3 years agoNot applicable
The error is gone an the measure shows data in the visual but it's still just one point in time, corresponding with the selection in the filter. It doesn't show the previous 12 months going back from that selected date as I expected it to do..
Any ideas?- johnt753 years ago
Super User
Hopefully this will do it
12 Months back = VAR CurrentDateTime = SELECTEDVALUE ( 'dim_Date'[EOM Date], MAX ( 'dim_Date'[EOM Date] ) ) VAR CurrentDate = DATE ( YEAR ( CurrentDateTime ), MONTH ( CurrentDateTime ), DAY ( CurrentDateTime ) ) VAR PreviousDate = DATE ( YEAR ( CurrentDateTime ) - 1, MONTH ( CurrentDateTime ), DAY ( CurrentDateTime ) ) VAR Result = CALCULATE ( SUM ( 'fact'[column] ), DATESBETWEEN ( 'Date'[Date], PreviousDate, CurrentDate ) ) RETURN Result- Anonymous3 years agoNot applicable
Nope still the same