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
req77
Helper I
Helper I

LOOKUPVALUE that search for the latest value

Hello,

I have two tables that follow this structure:

 

Table1

IDNamePositionYear-Month
1      Jack        Operator2021-01
1JackCleaner2021-02
2EliseDirector2021-01
2EliseDirector2021-02
3AudreyMechanic2021-01
3AudreyElectrical maintenance2021-02
3AudreyMechanic2021-03
4LeoWeb developer2021-05

 

Table2

IDName
1       Jack
2Elise
3Audrey
4Leo

I want to create a calculated column in Table2 that uses the ID column in both tables to searchs in Table1 for each person's most recent Position, based on Table1's Year-Month column. The expected result would be this:

 

IDNamePosition
1       Jack       Cleaner
2EliseDirector
3AudreyMechanic
4LeoWeb developer


Can someone help me?

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @req77 

 

You can summarize your Table 1 and create a new Table with the desired data, try this code to add a new table:

Table 2=
SUMMARIZE (
    'Table 1',
    'Table 1'[ID],
    'Table 1'[Name],
    "Position",
        CALCULATE (
            MAX ( 'Table 1'[Position] ),
            FILTER ( 'Table 1', 'Table 1'[Year-Month] = MAX ( 'Table 1'[Year-Month] ) )
        )
)

 

Output:

VahidDM_0-1633925332029.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

Hi @req77 

 

You can summarize your Table 1 and create a new Table with the desired data, try this code to add a new table:

Table 2=
SUMMARIZE (
    'Table 1',
    'Table 1'[ID],
    'Table 1'[Name],
    "Position",
        CALCULATE (
            MAX ( 'Table 1'[Position] ),
            FILTER ( 'Table 1', 'Table 1'[Year-Month] = MAX ( 'Table 1'[Year-Month] ) )
        )
)

 

Output:

VahidDM_0-1633925332029.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

@VahidDM you seem good with SUMMARIZE.  Any thoughts on this Forum question?  

Jihwan_Kim
Super User
Super User

Hi, please check the attached pbix file down below.

 

 

Picture2.png

 

Latest position CC =
VAR latestdate =
MAXX ( RELATEDTABLE ( Table1 ), Table1[monthenddate CC] )
VAR currentid = Table2[ID]
RETURN
MAXX (
FILTER (
Table1,
Table1[ID] = currentid
&& Table1[monthenddate CC] = latestdate
),
Table1[Position]
)
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.