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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Lucy64
Advocate II
Advocate II

Calculate Employee Retention

So my report is starting to look really good thanks to the help from this group.  Next step is to calculate Employee retention over a given period filtered by date.

 

So I need to calculate:

Number of employees starting the year =

Number of employees who started the year and finished the year =

 

I have a date table with:  Date; Year; Month

Personal table: HireDate; TermDate (TermDate is blank for Active employees)

 

I have already looked at other conversations on this topic but I could not get them to work for my project.  

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Lucy64,

 

For your requirement, you can take a look at below formulas.

 

Method A: use a new table to summary these records.

 

Table formula:

Table = DISTINCT(SELECTCOLUMNS('Date Table',"Year",[Year],"started and finished current year",COUNTX(FILTER(ALL(Sheet1),Sheet1[HireDate].[Year]=Sheet1[TermDate].[Year]&&Sheet1[HireDate].[Year]=EARLIER('Date Table'[Year])),[HireDate]),"Still emloyed",COUNTX(FILTER(ALL(Sheet1),Sheet1[TermDate]=BLANK()&&Sheet1[HireDate].[Year]=EARLIER('Date Table'[Year])),[HireDate])))

 

Capture.PNG

 

Notice: Date table is a calendar table with date, month, year; sheet1 is the table which has HireDate and TermDate.

Date Table = ADDCOLUMNS(CALENDAR(MIN(Sheet1[HireDate]),MAX(Sheet1[TermDate])),"Year",YEAR([Date]),"Month",MONTH([Date]))

 

Method B: use measures.

Measure formula:

started and finished this year = COUNTX(FILTER(ALL(Sheet1),Sheet1[HireDate].[Year]=Sheet1[TermDate].[Year]&&Sheet1[HireDate].[Year]=MAX(Sheet1[HireDate].[Year])),Sheet1[HireDate])

 

Still Employed = COUNTX(FILTER(ALL(Sheet1),Sheet1[TermDate]=BLANK()&&Sheet1[HireDate].[Year]=MAX(Sheet1[HireDate].[Year])),[HireDate])

 

Table visual:

Capture2.PNG

 

Regards,

Xiaoxin Sheng

 

View solution in original post

Vvelarde
Community Champion
Community Champion

hi @Lucy64

 

Try these measures,

 

StartingYear

 

Employees_StartingYear =
VAR countemployees =
    CALCULATE (
        COUNTROWS ( Personal ),
        FILTER (
            Personal,
            Personal[HireDate] <= FIRSTDATE ( DateTable[Date] )
                && OR (
                    YEAR ( Personal[TermDate] ) >= VALUES ( DateTable[Year] ),
                    Personal[TermDate] = BLANK ()
                )
        )
    )
RETURN
    IF ( countemployees > 0, countemployees, 0 )

StartingandFinishingYear

 

Employees_Starting_FinishingYear =
VAR countemployees =
    CALCULATE (
        COUNTROWS ( Personal ),
        FILTER (
            Personal,
            AND (
                Personal[HireDate] <= FIRSTDATE ( DateTable[Date] )
                    && OR (
                        YEAR ( Personal[TermDate] ) >= VALUES ( DateTable[Year] ),
                        Personal[TermDate] = BLANK ()
                    ),
                OR (
                    Personal[TermDate] >= LASTDATE ( DateTable[Date] ),
                    Personal[TermDate] = BLANK ()
                )
            )
        )
    )
RETURN
    IF ( countemployees > 0, countemployees, 0 )



Lima - Peru

View solution in original post

4 REPLIES 4
Vvelarde
Community Champion
Community Champion

hi @Lucy64

 

Try these measures,

 

StartingYear

 

Employees_StartingYear =
VAR countemployees =
    CALCULATE (
        COUNTROWS ( Personal ),
        FILTER (
            Personal,
            Personal[HireDate] <= FIRSTDATE ( DateTable[Date] )
                && OR (
                    YEAR ( Personal[TermDate] ) >= VALUES ( DateTable[Year] ),
                    Personal[TermDate] = BLANK ()
                )
        )
    )
RETURN
    IF ( countemployees > 0, countemployees, 0 )

StartingandFinishingYear

 

Employees_Starting_FinishingYear =
VAR countemployees =
    CALCULATE (
        COUNTROWS ( Personal ),
        FILTER (
            Personal,
            AND (
                Personal[HireDate] <= FIRSTDATE ( DateTable[Date] )
                    && OR (
                        YEAR ( Personal[TermDate] ) >= VALUES ( DateTable[Year] ),
                        Personal[TermDate] = BLANK ()
                    ),
                OR (
                    Personal[TermDate] >= LASTDATE ( DateTable[Date] ),
                    Personal[TermDate] = BLANK ()
                )
            )
        )
    )
RETURN
    IF ( countemployees > 0, countemployees, 0 )



Lima - Peru
Anonymous
Not applicable

Hi @Lucy64,

 

For your requirement, you can take a look at below formulas.

 

Method A: use a new table to summary these records.

 

Table formula:

Table = DISTINCT(SELECTCOLUMNS('Date Table',"Year",[Year],"started and finished current year",COUNTX(FILTER(ALL(Sheet1),Sheet1[HireDate].[Year]=Sheet1[TermDate].[Year]&&Sheet1[HireDate].[Year]=EARLIER('Date Table'[Year])),[HireDate]),"Still emloyed",COUNTX(FILTER(ALL(Sheet1),Sheet1[TermDate]=BLANK()&&Sheet1[HireDate].[Year]=EARLIER('Date Table'[Year])),[HireDate])))

 

Capture.PNG

 

Notice: Date table is a calendar table with date, month, year; sheet1 is the table which has HireDate and TermDate.

Date Table = ADDCOLUMNS(CALENDAR(MIN(Sheet1[HireDate]),MAX(Sheet1[TermDate])),"Year",YEAR([Date]),"Month",MONTH([Date]))

 

Method B: use measures.

Measure formula:

started and finished this year = COUNTX(FILTER(ALL(Sheet1),Sheet1[HireDate].[Year]=Sheet1[TermDate].[Year]&&Sheet1[HireDate].[Year]=MAX(Sheet1[HireDate].[Year])),Sheet1[HireDate])

 

Still Employed = COUNTX(FILTER(ALL(Sheet1),Sheet1[TermDate]=BLANK()&&Sheet1[HireDate].[Year]=MAX(Sheet1[HireDate].[Year])),[HireDate])

 

Table visual:

Capture2.PNG

 

Regards,

Xiaoxin Sheng

 

Lucy64
Advocate II
Advocate II

So I have the Number of employees starting the year: (total at end of previous year)

 

Number of Employees PY =

CALCULATE (

    [Balance],

    FILTER ( ALL ( DATES ), DATEADD(DATES[Date], 1, YEAR) <= MAX ( DATES[Date] ) )

)

 

Now I need to work out which of these empolyees are still emloyed at the end of the year!  So needs to check that the TermDate is Blank or greater than the end date of the filter.

 

If you want to find those who left in the same year they started, can you create a calculated column and set it to a 1 if the start year and term year are the same, otherwise set it to 0?

Then you can create a measure that takes the difference between the sum of those that started in a given year, and the sum of those that left the same year they started, for the given year (i.e. new calculated column)

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.