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

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

Reply
Cadams
Microsoft Employee
Microsoft Employee

Lookupvalue - Max value with duplicate max values

Good evening,

 

I'm wondering whether anyone can help. I'm trying to insert a new column in my table with a dax formula that returns the Primary Product based on the ID and max Value (see screenshot below with example data on Excel).

 

I'm currently using 'Lookupvalue' formula:

 

=lookupvalue ([product],[value],max([value]),[id],filter([table1],[id]=earlier([id])))

 

However, I keep getting the error (see screenshot below), as DAX can't figure out which max value to take. 

 

Cadams_1-1648245565555.png

 

What I'd like to do is just take either max duplicated primary product (it doesn't matter which), so long as the formula doesn't return an error.

 

Cadams_3-1648246145311.png

 

Can anyone figure out a way to do this, I'd really appreciate it!

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Cadams 
You can use

New Column =
VAR CurrentIDTable =
    CALCULATETABLE ( Table1, ALLEXCEPT ( Table1, Table1[ID] ) )
VAR MaxValue =
    MAXX ( CurrentIDTable, Table1[Value] )
VAR MaxValueProduct =
    CALCULATE ( MAX ( Table1[Product] ), Table1[Value] = MaxValue )
RETURN
    MaxValueProduct

View solution in original post

2 REPLIES 2
Cadams
Microsoft Employee
Microsoft Employee

That worked @tamerj1 , thank you so much !!

tamerj1
Super User
Super User

Hi @Cadams 
You can use

New Column =
VAR CurrentIDTable =
    CALCULATETABLE ( Table1, ALLEXCEPT ( Table1, Table1[ID] ) )
VAR MaxValue =
    MAXX ( CurrentIDTable, Table1[Value] )
VAR MaxValueProduct =
    CALCULATE ( MAX ( Table1[Product] ), Table1[Value] = MaxValue )
RETURN
    MaxValueProduct

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.