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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

How to identify new employees vs those that left

Each month I get a feed from HR (flat file) that has a list of all current employees for my department - everyone is identified with a unique code (PersonnelNumber).  When the data is refreshed in PowerBI each month I would like to automatically update two new columns in the dataset that would show me:

 

1) Column 'NewEmployee' flag (Yes/No, 1 or 0) - identify if the employee is new (did not appear in any previous month).

2) Column 'LastMonthofService' flag (Yes/No, 1 or 0) - identify if an employee is no longer showing up in the current month (would need to update the row for that employee in the previous month)

 

Would be great to also default the 1st period available in the dataset for "NewEmployee" to "N"

 

For example:

RalphKaz_0-1652301429335.png

 

Thank you!!

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create calculated column.

NewEmployee1 =
var _if=
IF(
    'Table'[Date]=MIN('Table'[Date]),"N",
CALCULATE(COUNT('Table'[Employee ID]),
FILTER(ALLSELECTED('Table'),
'Table'[Employee ID]=EARLIER('Table'[Employee ID])
&&'Table'[Date]>=EOMONTH('Table'[Date],-1)&&'Table'[Date]<=EARLIER('Table'[Date]))))
return
IF(
    _if=1,"Y","N")
LastMonthofService1 =
var _if=
CALCULATE(COUNT('Table'[Employee ID]),
FILTER(ALLSELECTED('Table'),
'Table'[Employee ID]=EARLIER('Table'[Employee ID])
&&'Table'[Date]<=EOMONTH('Table'[Date],+1)&&'Table'[Date]>=EARLIER('Table'[Date])))
return
IF(
    'Table'[Date]=MAX('Table'[Date]),BLANK(),
    IF(
    _if=1,"Y",
        "N")

2. Result:

vyangliumsft_0-1652768984651.png

 

Best Regards,

Liu Yang

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

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create calculated column.

NewEmployee1 =
var _if=
IF(
    'Table'[Date]=MIN('Table'[Date]),"N",
CALCULATE(COUNT('Table'[Employee ID]),
FILTER(ALLSELECTED('Table'),
'Table'[Employee ID]=EARLIER('Table'[Employee ID])
&&'Table'[Date]>=EOMONTH('Table'[Date],-1)&&'Table'[Date]<=EARLIER('Table'[Date]))))
return
IF(
    _if=1,"Y","N")
LastMonthofService1 =
var _if=
CALCULATE(COUNT('Table'[Employee ID]),
FILTER(ALLSELECTED('Table'),
'Table'[Employee ID]=EARLIER('Table'[Employee ID])
&&'Table'[Date]<=EOMONTH('Table'[Date],+1)&&'Table'[Date]>=EARLIER('Table'[Date])))
return
IF(
    'Table'[Date]=MAX('Table'[Date]),BLANK(),
    IF(
    _if=1,"Y",
        "N")

2. Result:

vyangliumsft_0-1652768984651.png

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

Thank you very much!  Works beautifully! 

amitchandak
Super User
Super User

@Anonymous , I have blog around Customer, In place of customer you use employee, You can use count(Table[Employee ID]) as your measure and try the formula

 

Customer Retention Part 1:
https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/ba-p/1361529

Anonymous
Not applicable

Thank you for that suggestion.  I tried to implement this and almost got it working but I would really prefer a way to implement this via adding columns to the table vs calculating it in a measure.  I want ability to create charts, graphs, totals, etc. and having a column there as a flag for each of the 3 scenarios just seems much easier.  I also noticed that in your example the "Retained" counts are not totalling up like the other two.

 

RalphKaz_0-1652395514197.png

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.