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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Mainer04401
Helper III
Helper III

Optimized MAXX & SUMMARIZE Expression

I need to calculate the maximum sales by any account in a user-specified geography, excluding the account in the filter or in the row.  I have an expression that works but its very sluggish and I wonder if there's opportunity for optimization.

 

When I tried to use the regular MAX, it appeared limited to row values and would not return an aggregate max.  For example, it worked fine at the zip code level, but when I viewed by state, it was still returning the maximum value of an account's sales at the zip code level rather than returning the maximum aggregate sales by account in a state.

 

Here's what I am using now.  Any thoughts?

 

Maximum Sales of Any Account =
var _SelectedAccount = if(HASONEVALUE(StoreList[AccountNumber]),firstnonblank(StoreList[LAccountNumber],true),0)
return
maxx(summarize(Market,Market[AccountNumber],"Max Sales", calculate(sum(Market[Sales_Volume]),
filter(all(Market[AccountNumber]),Market[AccountNumber]<>_SelectedAccount))),[Max Sales])
1 REPLY 1
v-easonf-msft
Community Support
Community Support

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors