Forum Discussion
Dynamic TopN with RankX
- Anonymous7 years ago
It is unclear on what you mean with "make it work different".
Are you trying to show the 4 items with the highest total sales over a year? or just during the month?
EDIT:
If took your example file and created the following measure:
SubTotal = CALCULATE(SUM(Base[Valor Total]);ALLEXCEPT(Base;Base[marca]))
I then changed your TopN Measure to:
TopN_total_sales = VAR SelectedTop = SELECTEDVALUE('TopN'[TopN]) var RankMarca = RANKX(ALL(Base[marca]);[SubTotal]) RETURN IF(RANKX(ALL(Base[marca]);[SubTotal])<=SelectedTop;[total_sales];BLANK())I'll get this as a result:
Result
I hope that this solves your problem!
Kind Regards.
PS: If it does solve your problem please mark this as answer.
It is unclear on what you mean with "make it work different".
Are you trying to show the 4 items with the highest total sales over a year? or just during the month?
EDIT:
If took your example file and created the following measure:
SubTotal = CALCULATE(SUM(Base[Valor Total]);ALLEXCEPT(Base;Base[marca]))
I then changed your TopN Measure to:
TopN_total_sales =
VAR SelectedTop = SELECTEDVALUE('TopN'[TopN])
var RankMarca = RANKX(ALL(Base[marca]);[SubTotal])
RETURN
IF(RANKX(ALL(Base[marca]);[SubTotal])<=SelectedTop;[total_sales];BLANK())
I'll get this as a result:
Result
I hope that this solves your problem!
Kind Regards.
PS: If it does solve your problem please mark this as answer.
Thank you , it worked perfectly!
In the TopN Measure, the var RankMarca is not used, so i deleted it. And [GrandTotal] should be [SubTotal], right?
Thanks