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

How to determine most recent entry per an employee (max date in a moment of time)

  • How can I create a DAX measure to show the most recent date entry per an employee?
  • So to see only the 'MAX' most recent entry per an employee number
  • I need to aggregate all the multiple record per employee to only keep the max record, most recent entry

 

For example, for Joe Blogs - I only want to see the record starting - 20/10/2020

For example, for Sam Bills - I only want to see the record starting - 19/10/2019

Employee numberNamePosition start datePosition end dateEmployment Basis
592342Joe Bloggs1/04/20121/05/2013Contract
592342Joe Bloggs2/05/20133/05/2015Part-time
592342Joe Bloggs4/05/201515/09/2019Full-time
592342Joe Bloggs16/09/201919/10/2020Part-time
592342Joe Bloggs20/10/2020 Full-time
347977Sam Bills19/10/201925/12/2020Part-time
347977Sam Bills26/12/202015/01/2021Casual
347977Sam Bills16/01/202131/12/2021Full-time
1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Do you want to create a calculated column? Then create a relationship with a table?

You need to create this column in the table with employee name, or create a calculated table.

Table 2 =
VAR t =
    SELECTCOLUMNS (
        'Table',
        "emp.no", 'Table'[Employee number],
        "emp.name", 'Table'[Name],
        "psd", 'Table'[Position start date],
        "lastest_date",
            CALCULATE (
                MAX ( 'Table'[Position start date] ),
                ALLEXCEPT ( 'Table', 'Table'[Name] )
            )
    )
RETURN
    FILTER ( t, [psd] = [lastest_date] )

View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Do you want to create a calculated column? Then create a relationship with a table?

You need to create this column in the table with employee name, or create a calculated table.

Table 2 =
VAR t =
    SELECTCOLUMNS (
        'Table',
        "emp.no", 'Table'[Employee number],
        "emp.name", 'Table'[Name],
        "psd", 'Table'[Position start date],
        "lastest_date",
            CALCULATE (
                MAX ( 'Table'[Position start date] ),
                ALLEXCEPT ( 'Table', 'Table'[Name] )
            )
    )
RETURN
    FILTER ( t, [psd] = [lastest_date] )
VahidDM
Super User
Super User

Hi @smb711 

 

Is that 19/10/2019 for Sam Bills correct?

BTW, try this measure:

Most Recent Date =
CALCULATE (
    MAX ( table[Position start date] ),
    ALLEXCEPT ( table, table[Name] )
)

 

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

Appreciate your Kudos!!

 

Thanks! How do I apply this to aggregate/filter down the number of options in the table? I am unable to create a relationship between this table and another table with multiple employee records even though as a result of the measure it has filtered down the multiple records to just the one most recent? 

 

"You can't create a relationship between these two columns because one of the columns must have unique values"

 

Do you have a suggested workaround, i.e. complete the calculation in the power query editor as a custom column and then filter (If so how?) 

 

I am trying to get information from another table with multiple records by forging a relationship one to many relationships with another table with multiple records per employee number. 

 

Apologies, for Sam Bills it would be 16/01/2021

 

To clarify, I only want to display the most current date record per an employee number 

Most recent date =
CALCULATE(
MAX(PBIPND_vwClassRank[StartDate]),
ALLEXCEPT('Date Table', 'Date Table'[Date])
)

 

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.