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
bourne2000
Helper V
Helper V

Calculate running total with two date columns in the Table

Hi

 

I have a below table

 

Employee NumberHired DateTermination DateStatus
33225/10/1994Monday, 1 August 2016Terminated
3394/01/1995Monday, 1 August 2016Terminated
60418/08/1998Monday, 1 August 2016Terminated
62424/11/1998Monday, 24 April 2017Terminated
66017/08/1999Friday, 16 June 2017Terminated
66814/09/1999Monday, 6 August 2018Terminated
77826/11/2001Thursday, 13 September 2018Terminated
79213/02/2002Tuesday, 9 October 2018Terminated
79711/03/2002Monday, 5 November 2018Terminated
8184/09/2001Monday, 4 March 2019Terminated
8194/09/2001Monday, 27 May 2019Terminated
83129/07/2002Sunday, 16 January 2022Terminated
8535/09/2002Monday, 26 August 2019Terminated
96917/10/2003 Active
97029/10/2003 Active
100421/04/2004 Active
101920/08/2004 Active
103927/09/2004 Active
108313/08/2005 Active
109325/08/2005 Active
114826/09/2005 Active
11574/11/2005 Active
118621/08/2006 Active

 

 

I want to calculate Running total for Active Employees and Terminated Employees. I calculated total active and total termination employees using below dax measures

 

 

Total Active = CALCULATE(COUNT('Table'[Employee Number]),'Table'[Status] = "Active")

 

 

 

Total Termination = CALCULATE(COUNT('Table'[Status]),'Table'[Status] = "Terminated")

 

 

I created a Date Table and connected it with the Hire date in the table. 

 

Then calculated running total for active employees as below

 

Active Employee RunningTotal = var MaxDate = MAX('Date'[Date])

RETURN

CALCULATE([Total Active],'Date'[Date] <= MaxDate,
ALL('Date'[Date]))

 

However, I am not able to calculate the running total for Terminated employees. Finally, I need to take the difference between active and running employees running total.

 

Can anyone advise how to do the above with two date columns in the table?

 

 

1 ACCEPTED SOLUTION
FarhanAhmed
Community Champion
Community Champion

You need to create an inactive relationship between your calendar date and terminated date.

 

and improve the DAX measure as 

 

Total Termination = CALCULATE(COUNT('Table'[Status]),'Table'[Status] = "Terminated",USERELATIONSHIP(Calendar[Date],Table[TerminationDate]))

  







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




View solution in original post

1 REPLY 1
FarhanAhmed
Community Champion
Community Champion

You need to create an inactive relationship between your calendar date and terminated date.

 

and improve the DAX measure as 

 

Total Termination = CALCULATE(COUNT('Table'[Status]),'Table'[Status] = "Terminated",USERELATIONSHIP(Calendar[Date],Table[TerminationDate]))

  







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




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.