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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
martti
Helper I
Helper I

Measure to calculate max of summarized table

I've hit a mind block figuring out a measure. I need it to extract the maximum revenues per month per salesman. I have an input table such as this:

DateSalesmanRevenue
01.11.2019A800
23.11.2019A

200

03.12.2019A300
05.11.2019B400
03.12.2019B500

The result should be 1000 for November and 500 for December (for all salesmen), since these are the maximum revenues per salesman for the relevant months. I cannot summarize the input table by salesman and date in query editor, since the actual input data is 10000+ rows with a lot more columns, and is compiled of multiple other data sources. I tried to summarize the input table in the measure itself with SUMMARIZE, but the formula 

 

CALCULATE(
    MAXX(
        SUMMARIZE(
            'Table' ;
            'Table'[Salesman] ;
            'Date_Table'[Dates].[Month] ;
            'Table'[Revenue]
        ) ;
        SUM('Table'[Revenue])
    ) ;
    ALL('Table'[Salesman])
)

 

seems to give the total revenue per month. The ALL('Table'[Salesman]) filter is needed, since the result has to be the same for all salesmen (the end result is a graph with x-axis salesmen, y-axis revenues, filtered for months).

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @martti 

 

Try this

test = 
VAR __tbl = 
GROUPBY(
    CALCULATETABLE( 'Table', ALL( 'Table' ), VALUES( Date_Table[Year Month] ) ) ,
    'Table'[Salesman],
    'Date_Table'[Year Month],
    "@sum", SUMX( CURRENTGROUP(), 'Table'[Revenue] ) 
)
RETURN 
MAXX( __tbl, [@sum] )
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

View solution in original post

7 REPLIES 7
Greg_Deckler
Community Champion
Community Champion

Perhaps try this:

 

Measure = 
    MAXX(
        SUMMARIZE(
            ALL('Table') ;
            'Table'[Salesman] ;
            'Date_Table'[Dates].[Month] ;
            'Table'[Revenue]
        ) ;
        SUM('Table'[Revenue])
    ) ;


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

For some reason, this still gives the revenue generated by the specific salesman when in reality it should be the maximum over all salesmen. I did try different positions in the formula for CALCULATE( , ALL('Table'[Salesman])), but it did not work when wrapping MAXX(), SUMMARIZE or the table itself in it. 

parry2k
Super User
Super User

@martti in date table add a month column and then use this measure

 

Measure = 
MAXX ( 
SUMMARIZE( 'Table', DateTable[Month], 'Table'[Salesman] ), 
CALCULATE( MAX ( 'Table'[Revenue] ) ) 
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

This somehow gives the maximum of a specific revenue per client, e.g. final result from my example is November - 800 for salesman A, 400 for salesman B; December - 300 for salesman A, 500 for salesman B.

Mariusz
Community Champion
Community Champion

Hi @martti 

 

Try this

test = 
VAR __tbl = 
GROUPBY(
    CALCULATETABLE( 'Table', ALL( 'Table' ), VALUES( Date_Table[Year Month] ) ) ,
    'Table'[Salesman],
    'Date_Table'[Year Month],
    "@sum", SUMX( CURRENTGROUP(), 'Table'[Revenue] ) 
)
RETURN 
MAXX( __tbl, [@sum] )
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

This works! BUT...It doesn't seem to respond to changes in filters that I apply.

My business has a series of business units (i.e. "BU") where I'd like to see the respective maximum for. So, in my underlying data, I have BU stored in another table. I'd like this m_MaxOrdersInYr to change based on the LOB I'm filtered on.

The code below works...how can I get it to respond dynamically when I filter on individual BUs?

m_MaxOrdersInYr = 
VAR _SummaryTable = 
GROUPBY(
    CALCULATETABLE('OSGM Data_LC',ALL('OSGM Data_LC'),VALUES('OSGM Data_LC'[r_YearOfPlan])),
    'OSGM Data_LC'[r_YearOfPlan],
    'OSGM Data_LC'[r_LOB],
    'OSGM Data_LC'[SBR Version],
    "@sum",SUMX(CURRENTGROUP(),'OSGM Data_LC'[ORDER_USD_d])
    )
RETURN
MAXX(_SummaryTable,[@sum])

 

Yes, this works perfectly! Thank you!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors