• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Calculate active employees for multiple years

powerbilead

New Member
Hi All,
Can I get some help in calculating number of active employees for each year based on hire date and term date. I have attached sample workbook with some data

Thanks in advance
 

Attachments

  • chandoo_analytics.xlsx
    11.6 KB · Views: 6
Since you posted in PQ/PP forum. I'm assuming that you want this in DAX.

General construct. Assuming that you have calendar table.

This assumes that active employee is those employee active at end of year. And Pivot has year as row field.
Code:
NumEmp :=
VAR curDate =
    MAX ( DimDate[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( empdata[emp_id] ),
        empdata[date_of_hire] <= curDate,
        OR ( ISBLANK ( empdata[date_of_term] ), empdata[date_of_term] > curDate )
    )

Exact calculation will depend on what you consider to be active employee in a given year.
 
Since you posted in PQ/PP forum. I'm assuming that you want this in DAX.

General construct. Assuming that you have calendar table.

This assumes that active employee is those employee active at end of year. And Pivot has year as row field.
Code:
NumEmp :=
VAR curDate =
    MAX ( DimDate[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( empdata[emp_id] ),
        empdata[date_of_hire] <= curDate,
        OR ( ISBLANK ( empdata[date_of_term] ), empdata[date_of_term] > curDate )
    )

Exact calculation will depend on what you consider to be active employee in a given year.


Thank you Sir. Yes I do have a calendar table. Much appreciated for your help in developing a DAX formula. Thanks again
 
Back
Top