Forum Discussion
How to use multiple Top N Filters!
- Anonymous3 years ago
Hi Anonymous ,
Please try below steps:
1. below is my test table
Table:
2. create a measure with below dax formula
Measure = VAR tmp = FILTER ( ALL ( 'Table' ), YEAR ( [Date] ) = 2022 ) VAR tmp1 = FILTER ( ALL ( 'Table' ), YEAR ( [Date] ) = 2023 ) VAR _a = TOPN ( 2, tmp, [Sale], DESC ) VAR _b = TOPN ( 2, tmp1, [Sale], DESC ) VAR _c = SELECTCOLUMNS ( _a, "CN", [Company Name] ) VAR _d = SELECTCOLUMNS ( _b, "CN", [Company Name] ) VAR _e = UNION ( _c, _d ) VAR cur_cn = SELECTEDVALUE ( 'Table'[Company Name] ) RETURN IF ( cur_cn IN _e, 1 )3. add a table visual with Table fields ,add measure to table visual filter pane and set
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
Please try below steps:
1. below is my test table
Table:
2. create a measure with below dax formula
Measure =
VAR tmp =
FILTER ( ALL ( 'Table' ), YEAR ( [Date] ) = 2022 )
VAR tmp1 =
FILTER ( ALL ( 'Table' ), YEAR ( [Date] ) = 2023 )
VAR _a =
TOPN ( 2, tmp, [Sale], DESC )
VAR _b =
TOPN ( 2, tmp1, [Sale], DESC )
VAR _c =
SELECTCOLUMNS ( _a, "CN", [Company Name] )
VAR _d =
SELECTCOLUMNS ( _b, "CN", [Company Name] )
VAR _e =
UNION ( _c, _d )
VAR cur_cn =
SELECTEDVALUE ( 'Table'[Company Name] )
RETURN
IF ( cur_cn IN _e, 1 )
3. add a table visual with Table fields ,add measure to table visual filter pane and set
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.