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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
RandomWombsis
Regular Visitor

Getting top category from a subset of values instead of the whole column

RandomWombsis_0-1671749776061.png

I have a list of companies (company_name) and their money amounts. I also have the line of business that the companies are in.

 

I need to show (in a card) that line of business that has the most total money out of the top 4 companies listed here. 

Note:
This would be easily achieved using top filter if the requirement was to show the top line of business out of the whole data. That would in this case be "siivous" as its money totals to 12000 which is more than any other category. 

However what I need is to dynamically get a "subset of top 4 companies" AND then take top category out of those. 

This would in this example result in "it-ala" being the biggest line of business out of that subset with 10000 as money amount.

Can this be achieved in any way?

3 REPLIES 3
RandomWombsis
Regular Visitor

That returns me the top sum of money, but how can I get the "line of business" that has the most total money out of the top 4 companies in that list?

 

amitchandak
Super User
Super User

@RandomWombsis , do need TOP one based on two columns

 

2 column top N = CALCULATE([Sum of Money], TOPN(1, SUMMARIZE(ALLSELECTED('Table'), 'Table'[Line of business], 'Table'[Company]), [Sum of Money],DESC),VALUES('Table'[Line of business]), VALUES('Table'[Company]) )

 

or

 

maxx( TOPN(1, SUMMARIZE(ALLSELECTED('Table'), 'Table'[Line of business], 'Table'[Company]), [Sum of Money],DESC),VALUES('Table'[Line of business]),[Company])

 

or

 

 

Concatenatex( TOPN(1, SUMMARIZE(ALLSELECTED('Table'), 'Table'[Line of business], 'Table'[Company]), [Sum of Money],DESC),VALUES('Table'[Line of business]),[Company] || '-' || [Line of business])

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

@RandomWombsis , do need TOP one based on two columns

 

2 column top N = CALCULATE([Sum of Money], TOPN(1, SUMMARIZE(ALLSELECTED('Table'), 'Table'[Line of business], 'Table'[Company]), [Sum of Money],DESC),VALUES('Table'[Line of business]), VALUES('Table'[Company]) )

 

or

 

maxx( TOPN(1, SUMMARIZE(ALLSELECTED('Table'), 'Table'[Line of business], 'Table'[Company]), [Sum of Money],DESC),VALUES('Table'[Line of business]),[Company])

 

or

 

 

Concatenatex( TOPN(1, SUMMARIZE(ALLSELECTED('Table'), 'Table'[Line of business], 'Table'[Company]), [Sum of Money],DESC),VALUES('Table'[Line of business]),[Company] || '-' || [Line of business])

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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