Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
rohanjha1988
Helper II
Helper II

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

 

1 ACCEPTED SOLUTION
Icey
Community Support
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.

View solution in original post

2 REPLIES 2
Icey
Community Support
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.

amitchandak
Super User
Super 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]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.