Forum Discussion
Using DAX variables in the filter function
- 4 years ago
Hi Anonymous
Please make a little bit change to your measure.
Top =
VAR Nth = 2
VAR Category =
ALLSELECTED ( 'Table'[Category] )
VAR Sales_ =
ADDCOLUMNS(
VALUES ('Table'[Category]),
"Rank", RANKX ( Category, [Total Sales] )
)
VAR FilterNThCategory =
FILTER(Sales_,[Rank]=Nth)
VAR NthLineName =
MINX(FilterNThCategory,'Table'[Category])
VAR Subtop =
CALCULATE ( [Total Sales], 'Table'[Category] =NthLineName)
RETURN
Subtop
Result should look like this:
Attached the pbix file as reference.
Best Regards,
Community Support Team _ Caiyun
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If you still have problems on it, please feel free to let us know. Thanks a lot!
Hi Anonymous
Please make a little bit change to your measure.
Top =
VAR Nth = 2
VAR Category =
ALLSELECTED ( 'Table'[Category] )
VAR Sales_ =
ADDCOLUMNS(
VALUES ('Table'[Category]),
"Rank", RANKX ( Category, [Total Sales] )
)
VAR FilterNThCategory =
FILTER(Sales_,[Rank]=Nth)
VAR NthLineName =
MINX(FilterNThCategory,'Table'[Category])
VAR Subtop =
CALCULATE ( [Total Sales], 'Table'[Category] =NthLineName)
RETURN
Subtop
Result should look like this:
Attached the pbix file as reference.
Best Regards,
Community Support Team _ Caiyun
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If you still have problems on it, please feel free to let us know. Thanks a lot!