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
Anonymous
Not applicable

Max value of a column based on another column's value

Hello, I'm trying to sum the max values of a column (Opportunity Age in Days) based on another column (Opportunity Number). The challenge is when the Opportunity Number appears more than once. For example, 640201 appears twice, but the value of 519 should also be factored into the calculation once.  Tried a few different measures without any luck. Hoping someone will show me the light. Thanks in advance. 

Opportunity NumberOpportunity Age in Days
72997227
669690309
640201519
640201519
673227141
668483190
69957916
662641217
73259771
67728098
86407326
661032214
3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

I checked FreemanZ's code and I think you just need _table part to sum the max age for each number.

Measure = 

VAR _table =

ADDCOLUMNS(

    VALUES(data[Opportunity Number]),

    "AgaMax",

    CALCULATE(MAX(data[Opportunity Age in Days]))

)

RETURN

SUMX(_table,[AgaMax])

 Result is as below.

RicoZhou_0-1672295782596.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you both. Should provide a bit more context...I'm using Excel's data model, not PBI. Was looking for some assistance with a Dax measure that would sum the 'Opportunity Age in Days' field, but only by unique Opportunity Number. This measure will be used in conjuction with the unique count [of Opportunity Number] to derive the avg sales cycle:  Avg Sales Cyle = Total Days / Deal Count. I'm struggling with Total Days measure so it excludes those values where the Opportunity Number is listed more than once. 

FreemanZ
Super User
Super User

hi @Anonymous 

try to create a measure like this: 

 

Measure =

VAR _table =

ADDCOLUMNS(

    VALUES(data[number]),

    "AgaMax",

    CALCULATE(MAX(data[Age]))

)

VAR _table1 =

TREATAS(

     _table,

     data[number],

     data[Age]

)

RETURN

SUMX(_table1, [AgaMax])

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.