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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
CupidC
Helper II
Helper II

Showing Top customers in a Table using TOPN

Hi all
I was trying to use TOPN function to show the Top 3 customers in a Table visual, but I couldn't figure it out what is wrong with my formula. any advice would be great 😞

 

Original Table:

A500
A300
A500
B700
B200
C323
C500
C300
D100
D700
D300
E220
E565
E667
F839
F122

 

My TopN Formula:

Top 3 customer =

VAR topcstuomer = topn(3,VALUES('Sales'[Name]),[Total sales],DESC)
Return
CALCULATE([Total sales],topcstuomer)
 
Result:
The result showing all customers instead of the top 3, but the total is correct - showing the sum of top3
CupidC_0-1653959308136.png

 

 

Result that I hope for:

CupidC_1-1653959416544.png

 

2 ACCEPTED SOLUTIONS
VahidDM
Super User
Super User

Hi @CupidC 

 

You can just add a simple filter on that visual like this to find those Top 3 items:

VahidDM_0-1653961087577.png

 

 

Output:

VahidDM_1-1653961098761.png

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Try these measures

Total = SUM(Data[Sales])
Measure = CALCULATE([Total],topn(3,ALL(Data[Customer]),[Total]),VALUES(Data[Customer]))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Try these measures

Total = SUM(Data[Sales])
Measure = CALCULATE([Total],topn(3,ALL(Data[Customer]),[Total]),VALUES(Data[Customer]))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

HI Ashish

 

Thanks. could you explain what "VALUES(Data[Customer])" does at the end..

 

It works, but not sure why it works......

 

Thanks

Cupid

 

Hi,

The VALUES() function returns a unique list of all the Customers.  So while the TOPN function returns the top 3 from among all customers, the return result in the visual just has 3 customers. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
VahidDM
Super User
Super User

Hi @CupidC 

 

You can just add a simple filter on that visual like this to find those Top 3 items:

VahidDM_0-1653961087577.png

 

 

Output:

VahidDM_1-1653961098761.png

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors
Top Kudoed Authors