Forum Discussion
Passing Slicer Selection value in DAX Filter
Hi aamer ,
This can be done using measures.
I don't know how your data is structure but I assume is something similar to the one below:
Date
Tranx_NUMBER
Column1
Column2
....
ColumnN
If you have a calendar table then you can add a measure for curent year and the previous 2 year that way you would be abble to make the count and further calculations.
Measures would be similar to this:
TransSelectedYear = DISTINCTCOUNT (Revenue_Lines[TRX_NUMBER])
TransSelectedYear - 1 = VAR Year_Selection = SELECTEDVALUE(DAte[Year])
Return
CALCULATE([TransselectedYear], FILTER(ALL(Date[Year]), Date[Year )= Year_Selection - 1]))
TransSelectedYear - 2 = VAR Year_Selection = SELECTEDVALUE(DAte[Year])
Return
CALCULATE([TransselectedYear], FILTER(ALL(Date[Year]), Date[Year )= Year_Selection - 2]))
Now this measures can be used to make the calculations.
If you share a sample data I can provide a better example.
No need to create additional tables on your model except the date table.
Felix - this is the correct way to do it. I was stumped on this also as intuitively you would be expected to work with the selected value expression directly. Passing in into a variable is the way to solve this. Much appreicated!