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 this since my service oppo has 84 count the rank is taking all these for 1 and second service mi has 80 count ,rank is taken as 85 .And for third its taking as rank 165.
v-yadongf-msft
3 years agoCommunity Support
Hi raj777karthik ,
Please try following DAX to create three measures:
Count = COUNT('Stack Tags'[Service])
Rank = RANKX(ALLSELECTED('Stack Tags'),[Count],,DESC,Dense)
Total count = CALCULATE([Count],FILTER(ALL('Stack Tags'),'Stack Tags'[Rank]<=5))
You will get result you want:
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
In Rank measure,im getting values 1 and 2.
- v-yadongf-msft3 years agoCommunity Support
- raj777karthik3 years agoMicrosoft Employee
Same as you have mentioned.Created measure for this.
Rank = RANKX(ALLSELECTED('Stack Tags'),[Count],,DESC,Dense)