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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
cflynn_29
Helper I
Helper I

Max of Sum Values

I have a table that has the following columns: School - Building Space - Facility Type - Area.

 

Facility Type has an Area and belongs to a Building Space. Essentially i was able to get the total area by each building space.

 

2.JPG

2.JPG

What i really want to do is when i filter down by Building Space is to return the Max and only the Max like so:

 

3.JPG

This is as far as i got.
 
Total Sum = SUM(Data[Area])
 
Max Value = MAXX(VALUES(Data[Building Space]),[Total Sum])
 
Max Value_2 = MAXX(VALUES(Data[School]),[Max Value])
 
Any help would be apprecaited.
 
Thanks
10 REPLIES 10
Anonymous
Not applicable

You have to iterate over all the visible values in the first column (the name of which you have not shown):

 

MAXX(
	ALLSELECTED( T[FirstColumn] ),
	[Total Sum]
)

 

Be careful, though, NOT to use this measure inside a measure that does iteration. If you do this, you'll very likely get something that's total garbage due to the way ALLSELECTED works behind the scenes. Just make the measure a top-level measure and never use it in other measures. You'll then be safe. If you want to know WHY, please read this article:

 

https://www.sqlbi.com/articles/the-definitive-guide-to-allselected/

 

Best
D

@Anonymous So it worked similarly to what my Max Value_2 Measure did but i only want it to return the Max Value and only the Max Value regardless of whats selected. I am using that for a bullet chart so in the example above the Max Value would always stay 4200 while the other areas would adjust and be measured against it. 

 

Then again i just might have to do this in excel that way theres a column of total area values by building space and then take the Max of that column.

 

Thanks

Anonymous
Not applicable

 

// This will work only if there is a
// separate dimension Schools and
// it's used for slicing.

[Max Across Building Space] =
	CALCULATE(
		MAXX(
			Schools,
			[Total Sum]
		),
		VALUES( Schools[Building Space] ),
		ALL( Schools )
	)

 

 

Try this one... This will give you the max of the measure across all schools with the same building space if there's only one school visible. For many schools... you'll figure out what it does 🙂

 

Best

D

@Anonymous  That was so close, its nearly there except instead of totaling all of the individual areas by building space it just selected their largest individual space. It just needs to Total them by Building Space and take its maxiumum.

 

In the image below its taking the largest individual space 3,800 as the Max but what it needs to do is take 400 + 3800 = 4200 and that would be the maximum returned. Then i'd be all set.

 

4.JPG

This is the meausre i used from what you showed earlier: 

Max Across Building Space = CALCULATE(MAXX(Data,[Total Sum]),VALUES(Data[Building Space]),ALL(Data[School]))
 
Data is the table name and school is a column name. 
Anonymous
Not applicable

[Max Across All Building Spaces] =
	CALCULATE(
		MAXX(
			VALUES( Data[Building Space] ),
			[Total Sum]
		),
		ALL( Data )
	)

 

Best

D

@Anonymous No dice on this one, the last one was closer and i dont think theres a solution to this. Thank you for all of the assistance though.

Anonymous
Not applicable

There certainly IS a solution but problem is nobody (so far) can understand what you really want because what you are showing us is not representative of the task. For instance, you are always showing Building Space as "Building." I don't think this is the only entry in this attribute.

You can do everything and anything with DAX.

Please explain the calculation on some GOOD examples.

Best
D
Greg_Deckler
Community Champion
Community Champion

Try:

Max Value = MAXX(ALL('Date'),[Area])


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...

@Greg_Deckler  Unfortunately that only gave the Max value of the Facility Type and not by Building Space. So instead of getting the value of 4200 it grabbed 3800.

I'm with @Anonymous on this one. Going to need to see:

1. sample data as text

2. expected output

3. logic as to how to get from point A to B

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



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...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.