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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sagidam
Frequent Visitor

How to use lookup and max on dax correctly

Hello friends,
I try to extract from the table the field of the greatest value, by field Id,
When I want to be filtered by field Bompname,
I would like to get the value in Ballance field
Example of a table "BALL"

id

compname

ballance

1

A

26

1

B

15

2

B

9

2

A

15

3

B

5

3

A

3

 

In this example I would like to receive

A=3

B=5

 

1 ACCEPTED SOLUTION
LivioLanzo
Solution Sage
Solution Sage

You can do it like this:

 

Capture.PNG

 

 

=
SUMX (
    VALUES ( BALL[compname] ),
    VAR MxID =
        CALCULATE (
            MAX ( BALL[id] )
        )
    RETURN
        CALCULATE (
            MAX ( BALL[ballance] ),
            BALL[id] = MxID
        )
)

 


 


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


Proud to be a Datanaut!  

View solution in original post

4 REPLIES 4
LivioLanzo
Solution Sage
Solution Sage

You can do it like this:

 

Capture.PNG

 

 

=
SUMX (
    VALUES ( BALL[compname] ),
    VAR MxID =
        CALCULATE (
            MAX ( BALL[id] )
        )
    RETURN
        CALCULATE (
            MAX ( BALL[ballance] ),
            BALL[id] = MxID
        )
)

 


 


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


Proud to be a Datanaut!  

Work like a charm

Thank you

ofirk
Resolver II
Resolver II

Hi @sagidam,

I expect there are several ways to do this... 

This one seemed to work for me:

 

Column = 
SUMX(
    FILTER(BALL, 
        [compname] = EARLIER([compname]) && 
        [id] = MAXX(BALL, [id])), 
    [ballance])

Results look like this (select "Don't summarize" for the visualization of the column):

 

results.PNG

sagidam
Frequent Visitor

sorry something dont work with the EARLIER syntax

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.