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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JohnHS
Frequent Visitor

Find the value from a related column for an aggregate?

In this case I want to find the date of the Max value of a Sum agregation.

 

In my example DevAdvance = Sum(Development[ADVANCE]) and the DateKey is from a Calendar table

where MAXX('Calendar',[DevAdvance]) = 57

I can see that the Max DevAdvance was on the 11-Apr-20 how can I return that date?

Annotation 2020-07-02 090028.jpg

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Not sure what context you are going to use this measure, but you could try an approach like this.

 

Date with Max =
VAR __summary =
    ADDCOLUMNS ( VALUES ( 'Calendar'[DateKey] ), "@DevAdvance", [DevAdvance] )
VAR __maxdevadv =
    MAXX ( __summary, [@DevAdvance] )
VAR __filtered =
    FILTER ( __summary, [@DevAdvance] = __maxdevadv )
RETURN
    MAXX ( __filtered, 'Calendar'[DateKey] )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Employee
Employee

Not sure what context you are going to use this measure, but you could try an approach like this.

 

Date with Max =
VAR __summary =
    ADDCOLUMNS ( VALUES ( 'Calendar'[DateKey] ), "@DevAdvance", [DevAdvance] )
VAR __maxdevadv =
    MAXX ( __summary, [@DevAdvance] )
VAR __filtered =
    FILTER ( __summary, [@DevAdvance] = __maxdevadv )
RETURN
    MAXX ( __filtered, 'Calendar'[DateKey] )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Works perfectly thank you.

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors