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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
loafers
Frequent Visitor

Return text value based on Max of another column and take earliest instance if multiple Max occurs

Hi,

 

I want get the Location for the max sales for each unique ID in table below. 

 

I have the following measure:

Measure = CALCULATE(VALUES('Table'[Location]),'Table','Table'[Sales]=MAX('Table'[Sales]))
 
The measure works if the max of the sales field only occurs once. However, if the max of sales for the Unique ID shows up multiple times, I run into an error. Is there a way to have it pick the earliest instance of the max? So in the table below, for unique ID 1, I would want to return 'A'

 

LocationUniqueIDSales
A150
B150
C140
D230
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @loafers ,

I have created a simple sample, please refer to it to see if it helps you.

Create a measure.

Measure = CALCULATE(SUM('Table'[Sales]),FILTER(ALL('Table'),'Table'[UniqueID]=SELECTEDVALUE('Table'[UniqueID])))

Then click the location field.

vpollymsft_0-1659598107046.pngvpollymsft_1-1659598113128.png

If I have misunderstood your menaing, please provide your pbix file without privacy information and desired output with more details.


Best Regards
Community Support Team _ Polly

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

3 REPLIES 3
Anonymous
Not applicable

Hi @loafers ,

I have created a simple sample, please refer to it to see if it helps you.

Create a measure.

Measure = CALCULATE(SUM('Table'[Sales]),FILTER(ALL('Table'),'Table'[UniqueID]=SELECTEDVALUE('Table'[UniqueID])))

Then click the location field.

vpollymsft_0-1659598107046.pngvpollymsft_1-1659598113128.png

If I have misunderstood your menaing, please provide your pbix file without privacy information and desired output with more details.


Best Regards
Community Support Team _ Polly

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

@loafers , Create a rank with tie break and use that visual level filter

Rank Tie breaker
https://community.powerbi.com/t5/Community-Blog/Breaking-Ties-in-Rankings-with-RANKX-Using-Multiple-...
https://databear.com/how-to-use-the-dax-rankx-function-in-power-bi/

 

 

Or Try TOPN : https://youtu.be/QIVEFp-QiOk

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

I have to dissect the rankx link a bit further but it looks like the values used are unique? 

 

My end result that I want from the original table posted is something like below where sales is total sales for the Location and UniqueID.

LocationUniqueIDSales
A1140
D230

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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