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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.