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
Brianoreilly
Helper II
Helper II

Dynamic Date Filter needed on Table with Two Date Rows: Retention analysis calculations

Hi Folks, 

 

I currently have an issue calculation a dynamic employee retention based on our HR System Data. 

 

I am hoping to devise a dynamic dashbaord, where HR can use a slicer connected to a date table that can recalculate based on the time frame selected. 

 

My Problem is, that I cannot relate the 'Date Table' to one of the columns as I require the use of two dates in the calculations. 

 

I currently require 3 calculations:

As Follows:

Formula 1 Required: Count of "Active Employees" before or equal to the Max Date in Date Table Filter
Formula 2 Required: Count of "Leavers" before or equal to the Max Date in Date Table Filter
Formula 3 Required: Retention: (Total Number of Leavers within the Max and Min Dates) / (Average Active Headcount per month within the Max and Min Dates)

 

Any help with trying to devise these measures would be greatly appreciated, as I am at a loss. 

 

Thanks, 

Brian.

 

Table 1: Employee Data Table 2: Date Table
Employee IDLatest Start DateDate Left 01/01/1900
800876918-Feb-17  02/01/1900
436521411-Dec-16  03/01/1900
436756217-Dec-16  04/01/1900
436489813-Dec-16  05/01/1900
436348611-Dec-16  06/01/1900
436918919-Dec-16  07/01/1900
437146411-Jan-17  08/01/1900
437144711-Jan-17  09/01/1900
436280711-Dec-16  10/01/1900
436379114-Dec-16  11/01/1900
436231401-Dec-16  12/01/1900
437057603-Jan-17  13/01/1900
802365020-Aug-17  14/01/1900
133432803-Dec-0928-Jul-17 15/01/1900
133694704-Dec-0901-Jul-17 16/01/1900
137147029-Nov-0924-Feb-17 17/01/1900
124826818-Jul-0922-Apr-17 18/01/1900
125780421-Aug-0920-Apr-17 19/01/1900
178187216-Nov-1130-Jan-17 ….
5 REPLIES 5
LivioLanzo
Solution Sage
Solution Sage

Hi @Brianoreilly

 

download my file: https://1drv.ms/u/s!AiiWkkwHZChHjxzyDJFSK_jjEjTs

 

let me know if something is not clear

 

 

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Hi @LivioLanzo

 

Appreciate the help.

Sorry but this doesn't do the trick for me, as I have thousands of records. 

 

I need something a bit more robust.

 

What I need are calculated measures as such.

Formula 1:

This counts the number of active employees per time period of when they started. 

 

 

Active Employee Count Per Month (Non Cumulative) = 
VAR currentDate = MAX('Date'[Date])
RETURN
    CALCULATE (
        COUNTA ('Employee Data'[Employee ID] ),USERELATIONSHIP('Date'[Date],'Employee Data'[Latest Start Date]),
        FILTER (
            'Employee Data',
            ( 'Employee Data'[Latest Start Date] <= currentDate
              )&& 'Employee Data'[Date Left] = BLANK() 
        )
    )

 

 

I then cumulate this by 

Active Employee Count Per Month (Cumulative) = 
CALCULATE(
	[Active Employee Count Per Month (Non Cumulative)],
	FILTER(
		ALLSELECTED('Date'[Date]),
		ISONORAFTER('Date'[Date], MAX('Date'[Date]), DESC)
	)
)

 These two formulas work correctly. 

 

I can do the same two formulas for leavers and change user relationship on date to leave date:

To get leavers per month and cumulative leavers total. 

 

I would survive if I could figure out one more formula. 

 

This formula would be the number of leavers between a filtered from date and a filtered to date. 

Ie. in the screenshot below:

The first graph shows the leavers in the quarter.

The second graph, shows the cumulative leavers, but starts on the very first date ever. I need this to cumulate from the 1st 2017 in the example attached. 

 

test.PNG

 

 

 

Code for black value in graph two:

Inactive Employee Count Per Month (Cumulative)2 = 
CALCULATE(
	[Inactive Employee Count Per Month (Non Cumulative)],
	FILTER(
		ALLSELECTED('Date'[Date]),
		ISONORAFTER('Date'[Date], MAX('Date'[Date]), DESC)
	)
)

Really appreciate any help. 

 

Thanks, 

Brian. 

hI @Brianoreilly

 

what do you mean by more robust? are the measure in my report slow? if so, there's an additional step that can be taken to make them faster.

 

You are going to need to modify your data a little, either within Power Query or via a calculated table, if you want to have a fast report. The way the data is at the moment with a start date and end date is not optimal and you need to build complicated DAX to make it work, and more complicated is the DAX slower is the report

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Hi @LivioLanzo

 

The ActiveEmployees table is too large it looks unfortunately. 

 

The method you advise would work brilliant, if my dataset wasn't so cumbersome. 

 

Thanks for the advise. 

I need an alternative, that I have nearly cracked. 

Just need to get one more formula working. 

 

Thanks,

 

test2.PNG

 Regards,

Brian. 

There is a way to further aggregate the activeEmployees table so it becomes much smaller than it is in the file I sent. If that's something you would consider let me know and I upload another file

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

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.