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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
danialsj
Frequent Visitor

Retrieve MAX row of SUMMARIZE table

I have used the SUMMARIZE DAX in a calculated column and the result is somthing like this (within the SUMMARIZE table):

 

BranchRevenue
233000
122500
312000

 

I want to retrieve the branch with the highest Revenue.
E.g. I want the calculated column to say 2 since it has the max revenue. 

 

My DAX looks like this currently:

MaxBranch =
var ID = Table1[ID]
var BRANCHCODE = Table1[BranchCode]
var IDTABLE = CALCULATETABLE(Table1, FILTER(Table1, Table1[ID] = ID))
var SUMTABLE = SUMMARIZE(IDTABLE, Table1[ID], Table1[BranchCode], "Branch", Table1[BranchCode], "Revenue", SUM(Table1[Revenue]))

return
MAXX(SUMTABLE, [Revenue])
 
In the above, I was only able to retrive the highest revenue. SUMTABLE is a grouping of revenue totals by ID then Branch. When I write MAXX(SUMTABLE, [Branch]) then it picks up branch 3 as that is the highest number value. However I want it to first find the highest revenue value and output the corresponding branch. Thanks!
 
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@danialsj , Assuming Revenue is a measure like Sum(table[Revenue])

 

Top 1 Branch Revenue Rank = CALCULATE([Revenue],TOPN(1,all(Table[Branch]),[Revenue],DESC),VALUES(Table[Branch]))

 

https://youtu.be/QIVEFp-QiOk

View solution in original post

wdx223_Daniel
Super User
Super User

RETURN

MAXX(TOPN(1,SUMTABLE,[Revenue]),[Branch])

View solution in original post

3 REPLIES 3
wdx223_Daniel
Super User
Super User

RETURN

MAXX(TOPN(1,SUMTABLE,[Revenue]),[Branch])

amitchandak
Super User
Super User

@danialsj , Assuming Revenue is a measure like Sum(table[Revenue])

 

Top 1 Branch Revenue Rank = CALCULATE([Revenue],TOPN(1,all(Table[Branch]),[Revenue],DESC),VALUES(Table[Branch]))

 

https://youtu.be/QIVEFp-QiOk

Thanks! I changed some things around the DAX you sent and it has worked. 

MAXX(TOPN(1, SUMTABLE, [Revenue],DESC), [Branch])

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors