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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.