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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.