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
frankhofmans
Helper IV
Helper IV

Count unique values with multiple results

hi PBI experts,

 

i have the following question:

 

i have a table with employee ID, start contract and end contract (or empty if the employee is still working):

 

EMP IDSTARTEND
0011 jan 20211 feb 2022
0021 mar 2021 
0031 apr 2021 
0041 mar 20211 may 2021
0041 jun 2021 
0051 jun 202110 jun 2021
0051 sep 2021 
0061 oct 20211 dec 2021
0071 oct 2021 

 

i want to count the number of unique employees that who were hired in a certain period, and the number of employees who left the company. But in a few cases, the same person left the company and is hired back (or gets a new contract).

So, in Q1 2021, the number of unique employees hired is 3 (001, 002, 004), and the number of unique employees left is 1 (001). In Q2, the number of unique employees hired is 1 (005). Employee 004 was already hired in a previous quarter and was still employed in Q2 (in april). 

 

Employee ID 005 started in Q2, but also left the company in Q2 (so counted as 1 in both started and left). But if i change the date filter from Quarter to Year (2021), 005 has to count as 1 (he was already hired in 2021, before getting a new contract).

 

Quarter:

QHiredLeft
Q13 (001,002,004)1 (001)
Q21 (005)1 (005)
Q31 (005) 
Q42 (006,007)1 (006)

 

Year:

YearHiredLeft
202172 (001,006)

 

How can i solve this with a measure?

 

Thanks in advance!

 

Regards, Frank

 

2 REPLIES 2
amitchandak
Super User
Super User

@frankhofmans , refer if my HR blog or attached file after signature can help

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

hi Amitchandak!

 

Thanks for your reply. Your file is very helpfull, but i have troubles with employees that have multipe contracts. I have the following date table:

 

EMPlOYEE IDSTARTEND
E0011-feb-2128-feb-21
E0011-mrt-2114-mei-22
E0021-mrt-2131-mrt-21
E0021-apr-21 
E0031-apr-211-aug-22
E0041-apr-21 
E0051-mei-2131-mei-21
E0051-jun-21 
E0061-jun-21 
E0071-jul-21 
E0081-jul-2131-jul-21
E0081-aug-21 
E0091-jul-2131-jul-21
E0091-aug-211-jul-22
E0101-aug-2131-aug-21
E0101-sep-21 
E0111-sep-21 
E0121-okt-211-dec-21
E0131-jan-22 
E0141-jan-221-jun-22

 

I want to create the following outcome:

 

 2021202120212021202220222022
 Q1Q2Q3Q4Q1Q2Q3
        
# Unique employees begin of period02611111311
# Unique employees started in period2451200
# Unique employees ended in period0 (E001 + E002 has a new contract in the same period)0 (E005 has a new contract in the same period)01022
# Unique employees end of period26111113119
# Unique employees active in period (# of unique employees with at least 1 working day in selected period)261112131311

 

And with the possibility to change the date in year of month:

 

 20212022
# Unique employees begin of period011
# Unique employees started in period122
# Unique employees ended in period14
# Unique employees end of period119
# Unique employees active in period1213

 

So when an employee is already employed, and he/she has a new contract in a certain periode, it doesn't count as 1, but as 0. Or when a employee is hired and get a 2nd contract (from a monthly contract to a year contract) it has to count as 1.

 

Do you have an idea to fix this?

 

Many thanks!

 

Regards, Frank

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.