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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Abdult
Regular Visitor

DAX

  1. Convert the below expression in DAX or explain how you will achieve the result if you have full year exit and headcount data stacked monthly

Annualized Attrition = (Total YTD Exits/YTD Average Headcount) * (12/Number of months passed)

1 ACCEPTED SOLUTION
FarhanAhmed
Community Champion
Community Champion

First you need to calculate Active Headcounts for each month/date. That means if person left/hire during that time, he must be included/excluded from active head counts. There should be "Leaving Date" , "Hiring Date" in your data.

 

Create a YTD measure of based on above.

 

Create a measure that will calculate exit only.

 

The architecture will include 1-active relationship between Date and Employee table. Lets say it is connected with Hiring Date.

 

Then there will be a inactive relationship between Date and Leaving date to calculate exits based on this relationship.

 

In below example there is a Column active and it will hold "1" for all the employees and "Left" column where employees left or Leaving date is not null

 

_Hire = CALCULATE(SUM(Employee[Active]),USERELATIONSHIP(PBI_DimDate[DateSecAlternateKey],Employee[HiringDate]))
_Hire YTD =  CALCULATE([_Hire],DATESYTD(PBI_DimDate[DateSecAlternateKey]))
_Left = CALCULATE(SUM(Employee[Left]),USERELATIONSHIP(PBI_DimDate[DateSecAlternateKey],Employee[LeavingDate]))

 

_ActiveAll = 
Var dt = Max(PBI_DimDate[DateSecAlternateKey])

RETURN

CALCULATE(COUNTROWS(Employee),FILTER(ALLEXCEPT(Employee,Employee[CountryCode]),(Employee[HiringDate]<=dt && (Employee[LeavingDate]>=dt || ISBLANK(Employee[LeavingDate])=TRUE()) )))

 

Then create your above formula using above measures..

 

Annualized Attrition = (Total YTD Exits/YTD Average Headcount) * (12/Number of months passed)







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

2 REPLIES 2
v-henryk-mstf
Community Support
Community Support

Hi @Abdult ,

 

Whether the advice given by @FarhanAhmed  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Looking forward to your feedback.


Best Regards,
Henry

FarhanAhmed
Community Champion
Community Champion

First you need to calculate Active Headcounts for each month/date. That means if person left/hire during that time, he must be included/excluded from active head counts. There should be "Leaving Date" , "Hiring Date" in your data.

 

Create a YTD measure of based on above.

 

Create a measure that will calculate exit only.

 

The architecture will include 1-active relationship between Date and Employee table. Lets say it is connected with Hiring Date.

 

Then there will be a inactive relationship between Date and Leaving date to calculate exits based on this relationship.

 

In below example there is a Column active and it will hold "1" for all the employees and "Left" column where employees left or Leaving date is not null

 

_Hire = CALCULATE(SUM(Employee[Active]),USERELATIONSHIP(PBI_DimDate[DateSecAlternateKey],Employee[HiringDate]))
_Hire YTD =  CALCULATE([_Hire],DATESYTD(PBI_DimDate[DateSecAlternateKey]))
_Left = CALCULATE(SUM(Employee[Left]),USERELATIONSHIP(PBI_DimDate[DateSecAlternateKey],Employee[LeavingDate]))

 

_ActiveAll = 
Var dt = Max(PBI_DimDate[DateSecAlternateKey])

RETURN

CALCULATE(COUNTROWS(Employee),FILTER(ALLEXCEPT(Employee,Employee[CountryCode]),(Employee[HiringDate]<=dt && (Employee[LeavingDate]>=dt || ISBLANK(Employee[LeavingDate])=TRUE()) )))

 

Then create your above formula using above measures..

 

Annualized Attrition = (Total YTD Exits/YTD Average Headcount) * (12/Number of months passed)







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

Proud to be a Super User!




Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.