Forum Discussion

rohanjha1988's avatar
rohanjha1988
Helper II
5 years ago
Solved

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_147927977469677.00
9956988658_154624747666777.00
9956988658_159401934019177.00
9956988658_147695638227377.00
9956988658_154771407269877.00
9956988658_147730977309677.00
9956988658_154503864569477.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

  • 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]))

  • Icey's avatar
    Icey
    Community 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.