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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

How to Display Highest Value in Column 2 for each unique value in Column 1

I do not want to delete duplicate rows.  I just want to display the row that has the highest value for the group of duplicates.  For example, I have two columns - one has doc ID, then other has a number.

DOC ID     Number

DOCA_1     6

DOCA_1     5

DOCA_1     2

DOCB_1     7

DOCB_1     9

 

I want to return:

DOCA_1     6

DOCB_1      9

I want to retain the information for the other rows for other visuals, so I do not want to remove the rows. 

I just want to display the highest value in column 2, for each unique item in column 1. 

 

Is there a way to do that?

 

Thanks!

2 ACCEPTED SOLUTIONS
Musadev
Resolver III
Resolver III

You want to create a measure to show highest value for each Doc ID?

 Try the below code to get the desire output.

Highest Value Per DOC_ID = 

MAXX(

    VALUES('YourTable'[DOC_ID]),

    CALCULATE(

        MAX('YourTable'[YourNumberColumn]),

        ALLEXCEPT('YourTable', 'YourTable'[DOC_ID])

    )

)

 

View solution in original post

amustafa
Super User
Super User

Hi @Anonymous You can do it in 3 ways. You can change Sum to Max on your Number column in your visual or create a measure or create a summary table.

 

amustafa_0-1708999993282.png

 

DAX Measure:

Max Number Measure = MAX(Table1[Number])

 

DAX Calculated summary table

MaxNumberPerDocID = 
SUMMARIZE(
    Table1,
    Table1[DOC_ID],
    "MaxNumber", MAX(Table1[Number])
)

 

 





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

Proud to be a Super User!




View solution in original post

5 REPLIES 5
amustafa
Super User
Super User

Hi @Anonymous You can do it in 3 ways. You can change Sum to Max on your Number column in your visual or create a measure or create a summary table.

 

amustafa_0-1708999993282.png

 

DAX Measure:

Max Number Measure = MAX(Table1[Number])

 

DAX Calculated summary table

MaxNumberPerDocID = 
SUMMARIZE(
    Table1,
    Table1[DOC_ID],
    "MaxNumber", MAX(Table1[Number])
)

 

 





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

Proud to be a Super User!




Anonymous
Not applicable

Brilliant!  The first solution worked perfectly and easily - thank you so much!!!

 

I will check the other options later - thanks for giving me options!! 🙂

 

P.S. Just checked - the other solutions also worked just as easily - thank you so much!!! 

Musadev
Resolver III
Resolver III

You want to create a measure to show highest value for each Doc ID?

 Try the below code to get the desire output.

Highest Value Per DOC_ID = 

MAXX(

    VALUES('YourTable'[DOC_ID]),

    CALCULATE(

        MAX('YourTable'[YourNumberColumn]),

        ALLEXCEPT('YourTable', 'YourTable'[DOC_ID])

    )

)

 

Anonymous
Not applicable

Your solution also worked!! 🙂 Thank you so much - this is an amazing community and just saved me HOURS of work - thank you!!

You are most welcome. I have joined recently and it is an amazing platform, where there is always someone to help. Good luck for your journey 

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.