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
EmJa
Frequent Visitor

Lookup related record in same table

Product table

 

Sku

IDPrice

Prod1_a

Prod15
Prod1_bProd16
Prod1_cProd17
Prod2_aProd27
Prod2_bProd26

 

What dax measure can be used to return the price of the MAX(Sku) for each ID?

i.e All Prod1 would show 7 and all Prod2 would show 6.

 

Thank you

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@EmJa  you can use a measure like this

Measure =
VAR _id =
    MAX ( 'Table 1'[ID] )
VAR _sku =
    CALCULATE (
        MAX ( 'Table 1'[Sku] ),
        FILTER (
            ALL ( 'Table 1' ),
            'Table 1'[ID] = _id
                && RIGHT ( 'Table 1'[Sku], 1 )
                    = CALCULATE (
                        RIGHT ( MAX ( 'Table 1'[Sku] ), 1 ),
                        ALLEXCEPT ( 'Table 1', 'Table 1'[ID] )
                    )
        )
    )
RETURN
    CALCULATE (
        MAX ( 'Table 1'[Price] ),
        FILTER ( ALL ( 'Table 1' ), 'Table 1'[ID] = _id && 'Table 1'[Sku] = _sku )
    )

 

 

smpa01_0-1641503775806.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

2 REPLIES 2
smpa01
Super User
Super User

@EmJa  you can use a measure like this

Measure =
VAR _id =
    MAX ( 'Table 1'[ID] )
VAR _sku =
    CALCULATE (
        MAX ( 'Table 1'[Sku] ),
        FILTER (
            ALL ( 'Table 1' ),
            'Table 1'[ID] = _id
                && RIGHT ( 'Table 1'[Sku], 1 )
                    = CALCULATE (
                        RIGHT ( MAX ( 'Table 1'[Sku] ), 1 ),
                        ALLEXCEPT ( 'Table 1', 'Table 1'[ID] )
                    )
        )
    )
RETURN
    CALCULATE (
        MAX ( 'Table 1'[Price] ),
        FILTER ( ALL ( 'Table 1' ), 'Table 1'[ID] = _id && 'Table 1'[Sku] = _sku )
    )

 

 

smpa01_0-1641503775806.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
EmJa
Frequent Visitor

Thank you @smpa01 , not just for the solution but for th concept. 

(That was a really quick response!)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.