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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Andonip
New Member

Employee Turnover Based on Month

Hello,

 

New user here and trying to build out our Employee Turnover figure. Usually in excel we have a view per month, the takes the date of the month and employee ID, so we can monitor month-on-month changes of various demographics.

 

Right now my data set looks something like this:

 

PeriodEmployee IDFirst NameLast NameDepartment
1123JohnSmithFinance
2444JaneDoeSales
3668BruceWayneCustomer Support
1123JohnSmithTax
2444JaneDoeSales
3668BruceWayneCustomer Support

 

What i find though is that my formula does no recognise the employee ID per period:

 

headcount = CALCULATE(DISTINCTCOUNT('Attrition HC'[Employee ID],FILTER('Attrition HC','Attrition HC'[Period]=1)))

 

So as a result, I am just counting everyone once rather than per month. Is this normal behaviour or is there something i can do to fix this?

 

Best regards,

Ap

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from @xifeng_L,, please allow me to provide another insight:
Hi,@Andonip 

For your first requirement, my understanding is that you need to group by each different period and calculate the number of people who always have a few different employee ids in each period:

Regarding the issue you raised, my solution is as follows:

1.First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1716260836090.png

2. Below are the measure I've created for your needs:

 

headcount = CALCULATE(DISTINCTCOUNT('Attrition HC'[Employee ID]),FILTER(ALLSELECTED('Attrition HC'),'Attrition HC'[Period]=MAX('Attrition HC'[Period])))

 

The Allselected() function retains, the filtering conditions that you grouped with the Max() function, thus satisfying your need to count once per period, rather than once per person.
Below is the content of the relevant documentation:

ALLSELECTED function (DAX) - DAX | Microsoft Learn

3.Here's my final result, which I hope meets your requirements.

vlinyulumsft_0-1716260937438.png

4.Secondly regarding your desire to count all the people and then divide by a different number of people in each period, my measure is as follows:

Measure = DIVIDE(CALCULATE(DISTINCTCOUNT('Attrition HC'[Employee ID]),FILTER(ALLSELECTED('Attrition HC'),'Attrition HC'[DATE]>=DATE(2024,1,1)&&'Attrition HC'[DATE]<=TODAY())),
CALCULATE(DISTINCTCOUNT('Attrition HC'[Employee ID]),FILTER(ALLSELECTED('Attrition HC'),'Attrition HC'[Period]=MAX('Attrition HC'[Period]))))

5.My end result is as follows:

vlinyulumsft_1-1716260978779.png

 

Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Andonip
New Member

Hi Xifeng,

Note exactly I suppose what I was trying to do with the calculation was if we for example take a year to date view, the calulcation would take me leavers, then divide by the distinct count of each period. It would besically allow me to see a true headcount each month.

Kind regards,

Anonymous
Not applicable

Thanks for the reply from @xifeng_L,, please allow me to provide another insight:
Hi,@Andonip 

For your first requirement, my understanding is that you need to group by each different period and calculate the number of people who always have a few different employee ids in each period:

Regarding the issue you raised, my solution is as follows:

1.First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1716260836090.png

2. Below are the measure I've created for your needs:

 

headcount = CALCULATE(DISTINCTCOUNT('Attrition HC'[Employee ID]),FILTER(ALLSELECTED('Attrition HC'),'Attrition HC'[Period]=MAX('Attrition HC'[Period])))

 

The Allselected() function retains, the filtering conditions that you grouped with the Max() function, thus satisfying your need to count once per period, rather than once per person.
Below is the content of the relevant documentation:

ALLSELECTED function (DAX) - DAX | Microsoft Learn

3.Here's my final result, which I hope meets your requirements.

vlinyulumsft_0-1716260937438.png

4.Secondly regarding your desire to count all the people and then divide by a different number of people in each period, my measure is as follows:

Measure = DIVIDE(CALCULATE(DISTINCTCOUNT('Attrition HC'[Employee ID]),FILTER(ALLSELECTED('Attrition HC'),'Attrition HC'[DATE]>=DATE(2024,1,1)&&'Attrition HC'[DATE]<=TODAY())),
CALCULATE(DISTINCTCOUNT('Attrition HC'[Employee ID]),FILTER(ALLSELECTED('Attrition HC'),'Attrition HC'[Period]=MAX('Attrition HC'[Period]))))

5.My end result is as follows:

vlinyulumsft_1-1716260978779.png

 

Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

xifeng_L
Super User
Super User

Hi @Andonip ,

 

Is the following result what you want?

 

xifeng_L_0-1715959710796.png

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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