Forum Discussion
Issue with TopN
Hi All,
I have a table in which date wise details of client visited is given. I am calculating the number of visits to top 10 frequently visited clients using TopN formula. The formula is as follow -
=CALCULATE([# Visits], TOPN(10, ALL(OutletVisit[Partner ID]), [# Visits]))
Now the problem is that for some Partner IDs the number of visits are same and the formula is taking all such clients as one. If I use the formula =CALCULATE([# Visits], TOPN(1, ALL(OutletVisit[Partner ID]), [# Visits])) then it returns 49 instead of 7.
Partner ID #Visits # Visit/Client
| 9956988658_1479279774696 | 7 | 7.00 |
| 9956988658_1546247476667 | 7 | 7.00 |
| 9956988658_1594019340191 | 7 | 7.00 |
| 9956988658_1476956382273 | 7 | 7.00 |
| 9956988658_1547714072698 | 7 | 7.00 |
| 9956988658_1477309773096 | 7 | 7.00 |
| 9956988658_1545038645694 | 7 | 7.00 |
How to solve this issue. Kindly help
Hi rohanjha1988 ,
Try this:
Measure = CALCULATE([# Visits], TOPN(10, VALUES(OutletVisit[Partner ID]), [# Visits]))If this doesn't work, please share us more details.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- amitchandakSuper User
rohanjha1988 , Create a Rank and use that in Top 10
rank = rankx(ALL(OutletVisit[Partner ID]),[# Visits],,desc,dense) + rand()/100
CALCULATE([# Visits], TOPN(10, ALL(OutletVisit[Partner ID]), [rank]), values(OutletVisit[Partner ID]))
- IceyCommunity Support
Hi rohanjha1988 ,
Try this:
Measure = CALCULATE([# Visits], TOPN(10, VALUES(OutletVisit[Partner ID]), [# Visits]))If this doesn't work, please share us more details.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.