Forum Discussion
Caculate Last N Month by using Slicer
- 5 years ago
Hi damit23183 ,
I have created a simliar sample file in the below that you can check, hopes it could help you in some ways.
Create a new year-month column both in date table and acutal table:
YearMonth = YEAR([Date])*100+MONTH([Date])Create a measure like this, put it in the visual filter and set its value as 1:
Measure = VAR tab = TOPN ( SELECTEDVALUE ( Parameter[Parameter] ), CALCULATETABLE ( DISTINCT ( 'Table'[YearMonth] ), FILTER ( ALL ( 'Table' ), 'Table'[YearMonth] <= SELECTEDVALUE ( 'Date'[YearMonth] ) ) ), [YearMonth] ) RETURN IF ( SELECTEDVALUE ( 'Table'[YearMonth] ) IN tab, 1, 0 )Best Regards,
Yingjie LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi damit23183 ,
I have created a simliar sample file in the below that you can check, hopes it could help you in some ways.
Create a new year-month column both in date table and acutal table:
YearMonth = YEAR([Date])*100+MONTH([Date])
Create a measure like this, put it in the visual filter and set its value as 1:
Measure =
VAR tab =
TOPN (
SELECTEDVALUE ( Parameter[Parameter] ),
CALCULATETABLE (
DISTINCT ( 'Table'[YearMonth] ),
FILTER (
ALL ( 'Table' ),
'Table'[YearMonth] <= SELECTEDVALUE ( 'Date'[YearMonth] )
)
),
[YearMonth]
)
RETURN
IF ( SELECTEDVALUE ( 'Table'[YearMonth] ) IN tab, 1, 0 )
Best Regards,
Yingjie Li
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.