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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Vishal7012
Regular Visitor

YTD attrition % calculation

Hi,

I am looking for the Year to Date (YTD) attrition % DAX as per the below formula. Year is from October - September.

 

YTD attrition % = ((No. of exits / Average Headcount) / No. of months completed in the year) * 12

 

No. of exits = Exits from 1-Oct till date

Average Headcount = Average of every month's headcount

No. of months completed in the year  = For eg. it is 3 as of today i.e. (October - December). This should be dynamic post every month completion

 

There are 2 separate tables for Headcount & attrition. While headcount table will have repetitive entries every month, attrition table will have unique employee data.

Headcount & Attrition tables will be uploaded on a monthly basis.

 

Example of the expected result: 

YTD % (October) = ((10/500)/1)*12 & the result is 24%.

YTD % (November) = ((12/504)/2)*12 & the result is 14%

YTD % (December) = ((16/502)/3)*12 & the result is 13%

 

 

 

3 REPLIES 3
FreemanZ
Super User
Super User

hi @Vishal7012 

What relevant columns do you have in both headcount and attrition table?

Hi @FreemanZ ,

 

Here are the samples of the 2 tables i'm using. Hope this helps.

 

1. Headcount table sample for every month. Will be uploaded every month.

Employee IDEmp NameJoining dateUpload Month
5001A1-Jan-02Oct-22
5002B1-Mar-15Oct-22
5003C1-Jun-22Oct-22
5004D1-Sep-22Oct-22
   Oct-22
5500E1-Jul-10Oct-22
    
    
5001A1-Jan-02Nov-22
5002B1-Mar-15Nov-22
5003C1-Jun-22Nov-22
5004D1-Sep-22Nov-22
   Nov-22
5504G1-Jul-21Nov-22
    
    
5001A1-Jan-02Dec-22
5002B1-Mar-15Dec-22
5003C1-Jun-22Dec-22
5004D1-Sep-22Dec-22
   Dec-22
5502K1-Jul-21Dec-22

 

2. Attrition Table sample. Will be uploaded every month.

Employee IDEmp NameLast working dateUpload month
1001X1-Oct-22Oct-22
1002Y10-Oct-22Oct-22
1003Z11-Oct-22Oct-22
1004ZA12-Oct-22Oct-22
1005ZB13-Oct-22Oct-22
1006ZX14-Oct-22Oct-22
1007ZAA15-Oct-22Oct-22
1008ZBB16-Oct-22Oct-22
1009ZXX17-Oct-22Oct-22
1010ZAP18-Oct-22Oct-22
2001ZBB1-Nov-22Nov-22
2002ZXX2-Nov-22Nov-22
2003ZAP3-Nov-22Nov-22
2004ZBB4-Nov-22Nov-22
2005ZXX5-Nov-22Nov-22
2006ZAP6-Nov-22Nov-22
2007ZBB7-Nov-22Nov-22
2008ZXX8-Nov-22Nov-22
2009ZAP9-Nov-22Nov-22
2010ZBB10-Nov-22Nov-22
2011ZXX11-Nov-22Nov-22
2012ZAP12-Nov-22Nov-22
30001ZXX1-Dec-22Dec-22
30002ZAP2-Dec-22Dec-22
30003ZXX3-Dec-22Dec-22
30004ZAP4-Dec-22Dec-22
30005ZXX5-Dec-22Dec-22
30006ZAP6-Dec-22Dec-22
30007ZXX7-Dec-22Dec-22
30008ZAP8-Dec-22Dec-22
30009ZXX9-Dec-22Dec-22
30010ZAP10-Dec-22Dec-22
30011ZXX11-Dec-22Dec-22
30012ZAP12-Dec-22Dec-22
30013ZXX13-Dec-22Dec-22
30014ZAP14-Dec-22Dec-22
30015ZXX15-Dec-22Dec-22
30016ZAP16-Dec-22Dec-22

hi @Vishal7012 

 

It hides some complexity:

1) suggest to add a column to convert the upload month to date, like Oct-2022 to 2022/10/01. 

2) plot a visual with the upload month and a measure like this:

Attrition% = 
VAR _month = MIN(Attrition[Upload month])
VAR _AvgHC = 
AVERAGEX(
    VALUES( HeadCount[Upload Month]),
    CALCULATE(COUNTROWS(HeadCount))
)
VAR _exit =
COUNTROWS(
    FILTER(ALL(Attrition), Attrition[Upload month]<=_month)
)
VAR _n = DATEDIFF(DATE(2022,10,1), _month, MONTH)+1
RETURN
(_exit/_AvgHC/_n)*12

 

With your sample data, it worked like this:

FreemanZ_1-1674397805258.png

 

the % is huge, but consistent with your sample data. 

 

p.s. plot with the upload month directly, not the date hierarchy. 

Helpful resources

Announcements
Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Top Solution Authors