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
raj777karthik
3 years agoMicrosoft Employee
In Rank measure,im getting values 1 and 2.
v-yadongf-msft
3 years agoCommunity Support
- raj777karthik3 years agoMicrosoft Employee
Same as you have mentioned.Created measure for this.
Rank = RANKX(ALLSELECTED('Stack Tags'),[Count],,DESC,Dense)
- v-yadongf-msft3 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.
- raj777karthik3 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))