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
rbustamante
Helper I
Helper I

How to obtain the max record for each one of the records

Hello,

I have the following table and I need DAX sentence to obtain the right table, that are the maximun values record of the left table.

rbustamante_0-1613946601024.png

Thanks in advance.

 

4 REPLIES 4
Nathaniel_C
Super User
Super User

Max.PNG

Hi @rbustamante , 

Try this:

 

Max value = 
var _curId = MAX(SourceTable[ID]) //Get Current ID
var _curValue = MAX(SourceTable[Value]) //Get current value


var _calc = CALCULATE(MAX(SourceTable[Value]),FILTER(ALLEXCEPT(SourceTable,SourceTable[ID]), MAX(SourceTable[ID])=_curId))

Return 

IF(_curValue =  _calc,_calc)

 

If you leave off the value column, and just use the measure, you will get this.

 

max1.PNG


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for the response.

What do you mean whe you said "If you leave off the value column, and just use the measure, you will get this."?

Hi @rbustamante ,
I created the table visual from the source table with 4 columns; Group, ID, Value, Max Value.  The Max Value is the measure that I created.  This shows all the values, and blanks in the measure column.

 

If you create the table with only Group, ID, and my measure Max Value you will see that the the reduced table with no blanks that more closely matches your table to the right of Desired Result.  It just depends on what you want to show.  A measure has a much smaller footprint than a calculated column.  It just depends on what you are using these values to do.

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




lbendlin
Super User
Super User

Please  provide more information. Should this be a calculated column or a measure?

Here is how a calculated column would look like:

Include = 
var m = CALCULATE(max('Table'[Value]),ALLEXCEPT('Table','Table'[Id]))
return if('Table'[Value]=m,1,0)

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