Forum Discussion

Saad_Hanif456's avatar
2 years ago
Solved

New Joiners Count

Dear Experts,

Need to calculate how many employees joined each month but the trick is in the following table example: (Remarks column is given for help)

S.NoPayroll MonthCodeName CNIC Hiring DateRemarks
11-Jan-2410438Imtiaz455558877711-Jan-24Hired
21-Jan-2410320Safdar455558877721-Feb-23 
31-Jan-2410553Ali 455558877731-Oct-23 
41-Jan-2410042Hussain455558877741-Jan-24HIred
51-Feb-2410438Imtiaz455558877711-Jan-24 
61-Feb-2410320Safdar455558877721-Feb-23 
71-Feb-2410553Ali 455558877731-Oct-23 
81-Feb-2410042Hussain455558877741-Jan-24 
91-Feb-2410953Waseem455558877761-Feb-24Hired
101-Feb-2410993khurram455558877771-Feb-24hired
111-Mar-2410555Imtiaz455558877711-Mar-24Confirmed with new Emp ID, CNIC is same
121-Mar-2410556Hussain455558877741-Mar-24Confirmed with new Emp ID, CNIC is same
131-Mar-2410399Arbaas455558877751-Feb-24 
141-Mar-2410993khurram455558877771-Feb-24 
151-Mar-2410959maheen455558877801-Mar-24Hired
161-Apr-2410555Imtiaz455558877711-Mar-24 
171-Apr-2410556Hussain455558877741-Mar-24 
181-Apr-2410959maheen455558877801-Mar-24 
191-Apr-2410541Idrees4555588778125-Mar-24He was hired in March 2024 but was included in April 2024 payroll. I want him to be counted in the month of March 2024 only as per hiring date
201-Apr-2410557Waseem455558877761-Apr-24Confirmed with new Emp ID
211-Apr-2410558khurram455558877771-Apr-24Confirmed with new Emp ID

 

1- Imtiaz and safdar joined in Jan 2024 and confirmed in Mar 2024 with a new emp ID, CNIC is the same. I do not want to count them in March 2024 because they were already counted in Jan 2024. (That i have already done with DAX with the following)

Step 1: Add a calculated column to determine the first hiring date for each CNIC:

firsthiringdate =

CALCULATE(

    MIN(Payroll[Hiring Date]),

    ALLEXCEPT(Payroll,Payroll[CNIC]))



Step 2: Create a measure to count the number of unique employees who joined in each month based on this first hiring date

VAR CurrentMonth = SELECTEDVALUE(Payroll[Payroll Month])

RETURN

CALCULATE(

    DISTINCTCOUNT(Payroll[CNIC]),

    FILTER(

        Payroll,

        Payroll[firsthiringdate] >= EOMONTH(CurrentMonth, -1) +1 &&

        Payroll[firsthiringdate] <= EOMONTH(CurrentMonth,1)))

MonthsResult
Jan 2
Feb2
Mar1
Apr0

2 - However, Mr. idrees who was joined in March 2024 is not being counted since he has been added in the Payroll of April 2024
I want his count reflects in the month of March 2024 but the with aforemention DAX he is not refelecting in March 2024 neither in April 2024
MonthsResultRequired 
Jan 22
Feb22
Mar12
Apr00

Please help in this regards and suggest the DAX where my both 1 and 2  condition gets fulfilled so that i can move forward quickly.
PBX FIle is enclosed for working (https://drive.google.com/file/d/1N7qHOwNoO9nsP_bkmLxt4keIBanrcxAA/view?usp=sharing )

Regards
Saad Hanif

  • Dear Rupak_bi,

    I wanted the result same as in the following table visual:

    Note: Have the silcer of calendar[month], calender[year] and department [name] on the canvas

    Month Name Hire
    JanImtiaz 1
    JanHussain1
    Feb Waseem1
    Feb Khurram1
    Feb Arbaas1
    MarMaheen1
    MarIdress1

     

    Regards,

    Saad Hanif

5 Replies

  • Hi I think below will be your expected out based on data. Feb count will be 3 , Khurram, Arbaas, Waseem

     

     

    • Saad_Hanif456's avatar
      Saad_Hanif456
      Helper I

      Dear Rupak_bi,

      I wanted the result same as in the following table visual:

      Note: Have the silcer of calendar[month], calender[year] and department [name] on the canvas

      Month Name Hire
      JanImtiaz 1
      JanHussain1
      Feb Waseem1
      Feb Khurram1
      Feb Arbaas1
      MarMaheen1
      MarIdress1

       

      Regards,

      Saad Hanif

      • Rupak_bi's avatar
        Rupak_bi
        Super User

        just update the table relationship to "firsthiredate"

        If this solves your problem, Plz accept it as solution.