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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Finding DATEDIFF between date employed and last recorded entry

I have 2 tables:

• One that shows a list of employees and their hire date
• One that shows a list of actions completed, the date it was completed, and the employee who completed that action

I need to create a column on the first table that shows the time between the employees hire date ('Employees'[HireDate]) and the last time they completed an activity ('Actions'[DateCompleted]).

What DAX expression can I use for this? I've tried using:
 
DATEDIFF('Employees'[HireDate], MAX('Actions'[DateCompleted]), DAY) 

But this only returns the days between their hire date and the last action completed in the 'Actions' table, not the last 'Action' completed by the respective employee.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I assume the two tables does not have any relationship.

I tried to create a sample pbix file like below.

 

In case there is no relationship between two tables, please try like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1667762993038.png

 

Days between hired and action completed CC =
DATEDIFF (
    Employee[Hire date],
    MAXX (
        FILTER ( 'Action', 'Action'[Employee] = EARLIER ( Employee[Employee] ) ),
        'Action'[Complete date]
    ),
    DAY
)

 


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I assume the two tables does not have any relationship.

I tried to create a sample pbix file like below.

 

In case there is no relationship between two tables, please try like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1667762993038.png

 

Days between hired and action completed CC =
DATEDIFF (
    Employee[Hire date],
    MAXX (
        FILTER ( 'Action', 'Action'[Employee] = EARLIER ( Employee[Employee] ) ),
        'Action'[Complete date]
    ),
    DAY
)

 


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Worked like a charm! Thanks so much!!

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.