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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JMG241188
Helper I
Helper I

Aggregating the results of a DAX measure to arrive as a Sum of the Filtered results

Hey,

 

I have an issue with the formula below, it works in certain visuals, but not for others.

 

Ultimately what this formula does is compare the current contract ID and see if that is equal to the MAX version of that contract ID and returns the Version Number corresponding to that contract.

 

LatestVersion = var _max = maxx(filter(ALLSELECTED(Contracts), Contracts[Master Contract Version Id] = Max(Contracts[Master Contract Version Id])), Contracts[Version Number])
return
CALCULATE(max(Contracts[Version Number]), filter((Contracts) ,  Contracts[Version Number] = _max))
 
This is OK to use as a filter on tables where each contract is split out on the visual, but it doesn't work when the data is aggregated.
 
What I need to do is return the $ limit of each of the latest versions, summed up together. I amended the formula to return the Overall Limit $, but again, it works at line level, but when aggregating contracts together, it only returns one value. Which is likely expected with the DAX measure, but I need to know how to take all of these individual "latest" limits, and sum them together in a total.
 
LatestVersionLimit = var _max = maxx(filter(ALLSELECTED(Contracts), Contracts[Master Contract Version Id] = Max(Contracts[Master Contract Version Id])), Contracts[Version Number])
return
CALCULATE(SUM('Contract Sections'[Overall Limit]), filter((Contracts) ,  Contracts[Version Number] = _max))
 
Any help would be greatly appreciated.
 
Thanks so much,
 
J
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@JMG241188 This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@JMG241188 This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thanks so much Greg, very theoretically complex yet ultimately simple solution. Perfect! Legend!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.