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
Anonymous
Not applicable

DAX Formula to find last day worked within a week

I am trying to develop a formula to calculate the last working day within a work week for a group of employees.  A work week runs from Monday to Sunday.  The group as a whole will work 5-7 days per week, where an individual may work any number of days during the week.  The Last Work Date will be the same for all employees who work during a work week regardless of the number of days worked during the week.

 

My table is represented below.   I need to calculate the last date worked for the group of each week.  I have filled in the Last Work Date column with the desired results.  Please note, in the example below RC did not record production on 6/27/20, but the Last Day Worked is 6/27/20 based on production dates of the other employees.

 

EmployeeWeek Beginning DateProductionProduction DateLast Work Date of Week
RC6/8/202056/13/20206/13/2020
RC6/15/202046/16/20206/19/2020
TB6/15/202016/16/20206/19/2020
RC6/15/202036/17/20206/19/2020
TB6/15/202026/17/20206/19/2020
FB6/15/202036/18/20206/19/2020
RC6/15/202046/18/20206/19/2020
TB6/15/202026/18/20206/19/2020
FB6/15/202056/19/20206/19/2020
RC6/15/202016/19/20206/19/2020
TB6/15/202016/19/20206/19/2020
FB6/22/202036/22/20206/27/2020
RC6/22/202056/22/20206/27/2020
TB6/22/202016/22/20206/27/2020
FB6/22/202026/23/20206/27/2020
RC6/22/202026/23/20206/27/2020
TB6/22/202046/23/20206/27/2020
FB6/22/202036/24/20206/27/2020
RC6/22/202016/24/20206/27/2020
TB6/22/202056/24/20206/27/2020
RC6/22/202036/25/20206/27/2020
TB6/22/2020116/25/20206/27/2020
FB6/22/202086/26/20206/27/2020
RC6/22/202046/26/20206/27/2020
TB6/22/202026/26/20206/27/2020
FB6/22/202026/27/20206/27/2020
TB6/22/202046/27/20206/27/2020

 

Any assistance would be appreciated.

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@lbendlin   You were close.  The Last Work Date of Week is the value I'm trying to calculate.  The correct formula would be:

 

CALCULATE(max(Worked[Production Date]),ALLEXCEPT(Worked,Worked[Week Beginning Date]))

 

Thanks,  I would have sworn I tried this formula before I posted the question.

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

Here's a solution that doesn't require any computation at all

 

lbendlin_0-1597695363158.png

 

Anonymous
Not applicable

@lbendlin   Thanks, but I need a column in the table because I will need it for another calculation.  Ultimately, I will summarize the production by the Week Beginning Date and compute the average for the week based on the datediff(week beginning date,last day worked).

 

 

Last Day Worked := CALCULATE(max(Worked[Production Date]),ALLEXCEPT(Worked,Worked[Last Work Date of Week]))
Anonymous
Not applicable

@lbendlin   You were close.  The Last Work Date of Week is the value I'm trying to calculate.  The correct formula would be:

 

CALCULATE(max(Worked[Production Date]),ALLEXCEPT(Worked,Worked[Week Beginning Date]))

 

Thanks,  I would have sworn I tried this formula before I posted the question.

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.

Top Solution Authors