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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Show associated name (string) of max value per ID (group)

Hi experts!

 

I'm in need of some help. I have a table where I show the registration ID's (not unique), name of the instructor, the amount of ID's per instructor and a column where I show the MAX amount of ID's per instructor. Per row I can see the max amount of corresponding ID's of the instructor.

 

How I created the Max ID's column:

 

Max ID's = 
CALCULATE(MAX(Activity[Amount of ID's (per instructor)]),
ALLEXCEPT(Activity,Activity[Registration ID]))

 

 

This is what I have now:

 

Registration IDName InstructorAmount of ID's (per instructor)Max ID's
500101Arjen15
500101Ruben25
500101Wouter55
500102Jan13
500102Klaas33
500103Nick48
500103Tim88

 

Now my question is: How do I get the associated name of the max value in each row per ID. The 'Name of Max' needs to be in a new column. Like in the following example:

 

Registration IDName InstructorAmount of ID's (per instructor)Max ID'sName of Max
500101Arjen15Wouter
500101Ruben25Wouter
500101Wouter55Wouter
500102Jan13Klaas
500102Klaas33Klaas
500103Nick48Tim
500103Tim88Tim

 

If you want the pbix file, you can download it from my OneDrive: https://hrnl-my.sharepoint.com/:u:/g/personal/0972624_hr_nl/EZPmTmUGRfVMq9k1huLCKeMBnoYF8gL8sUoufoqj... 

 

Help is appreciated a lot!

Thanks!

- Arjen

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

You can try to use the following measure formula to get the name of max id and group by current id:

Name of Max ID =
VAR currID =
    SELECTEDVALUE ( Activity[Registration ID] )
VAR maxAID =
    CALCULATE (
        MAX ( Activity[Amount of ID's (per instructor)] ),
        ALLSELECTED ( Activity ),
        VALUES ( Activity[Registration ID] )
    )
RETURN
    LOOKUPVALUE (
        Activity[Name Instructor],
        Activity[Registration ID], currID,
        Activity[Amount of ID's (per instructor)], maxAID
    )

Regards,

Xiaoxin Sheng

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

@Anonymous That's Lookup Min/Max: Lookup Min/Max - Microsoft Power BI Community



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks Greg Deckler,

 

That's indeed what I need and tried. There is one problem. I get the max of all ID's, like shown underneath:

 

Registration IDName InstructorAmount of ID's (per instructor)Max ID'sName of Max
500101Arjen15Tim
500101Ruben25Tim
500101Wouter55Tim
500102Jan13Tim
500102Klaas33Tim
500103Nick48Tim
500103Tim88Tim

 

I need to get the name per registration ID. So for 500101 I need to see Wouter as solution in the first three rows. See next example:

 

Registration IDName InstructorAmount of ID's (per instructor)Max ID'sName of Max
500101Arjen15Wouter
500101Ruben25Wouter
500101Wouter55Wouter
500102Jan13Klaas
500102Klaas33Klaas
500103Nick48Tim
500103Tim88Tim

 

How do I categorize that?

 

Much appreciated!

- Arjen

Anonymous
Not applicable

Hi @Anonymous,

You can try to use the following measure formula to get the name of max id and group by current id:

Name of Max ID =
VAR currID =
    SELECTEDVALUE ( Activity[Registration ID] )
VAR maxAID =
    CALCULATE (
        MAX ( Activity[Amount of ID's (per instructor)] ),
        ALLSELECTED ( Activity ),
        VALUES ( Activity[Registration ID] )
    )
RETURN
    LOOKUPVALUE (
        Activity[Name Instructor],
        Activity[Registration ID], currID,
        Activity[Amount of ID's (per instructor)], maxAID
    )

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hi Xiaoxin Sheng, 

 

Thanks a lot for your solution! This is indeed what I needed. 

Do you have any idea if this is also possible in a new calculated column?

 

Regards,

- Arjen

Anonymous
Not applicable

Hi @Anonymous,

Ok, you can take a look at the calculated column formula version: 

Name of Max ID =
VAR currID = Activity[Registration ID]
VAR maxAID =
    CALCULATE (
        MAX ( Activity[Amount of ID's (per instructor)] ),
        FILTER (
            ALL ( Activity ),
            [Registration ID] = EARLIER ( Activity[Registration ID] )
        )
    )
RETURN
    LOOKUPVALUE (
        Activity[Name Instructor],
        Activity[Registration ID], currID,
        Activity[Amount of ID's (per instructor)], maxAID
    )

Notice:

1. calculated column expression does not respond with filter effects, if you want to get the filtered result dynamically, please use the measure version instead.

2. data level of power bi:

Database(external) -> query table(query, custom function, query parameters) -> data model table(table, calculate column/table) -> data view with virtual tables(measure, visual, filter, slicer)

Regards,
Xiaoxin Sheng

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors