Forum Discussion
raj777karthik
3 years agoMicrosoft Employee
TOPN dax function as variable
Need to show top 5 services in table visual. Service Name Count Total Count Apple 43 346 Samsumg 67 346 mi 80 346 oppo 84 346 google 72 346 Measure written we...
- 3 years ago
v-yadongf-msft
3 years agoCommunity Support
Hi raj777karthik ,
OK, I know the reason of the problem.
Please try following DAX:
Rank = IF(HASONEVALUE('Stack Tags'[Service]),
RANKX(ALL('Stack Tags'[Service]),[Count],,DESC,Dense)
)
Best regards,
Yadong Fang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
raj777karthik
3 years agoMicrosoft Employee
Hi,
Thanks Rank is working fine as expected,but the total count measure is returning all the values.
Total count = CALCULATE([Count],FILTER(ALL('Stack Tags'),'Stack Tags'[Rank]<=5))
- v-yadongf-msft3 years agoCommunity Support
Hi raj777karthik ,
Can you tell me how the [Count] measure did you write?
It's better to share with me a screenshot of the original data (hide sensitive information).
Best regards
Yadong Fang
- raj777karthik3 years agoMicrosoft Employee
Measure written:
Count = COUNT('Stack Tags'[Service])Rank = IF(HASONEVALUE('Stack Tags'[Service]),RANKX(ALL('Stack Tags'[Service]),[Count],,DESC,Dense))Total count = CALCULATE([Count],FILTER(ALL('Stack Tags'),'Stack Tags'[Rank]<=5)) - v-yadongf-msft3 years agoCommunity Support
- raj777karthik3 years agoMicrosoft Employee
Thanks Yadong.Its working fine.