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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rouxknee
Frequent Visitor

Display employee retention rate by decimal years

Hello!  I have a dataset that includes employee tenure in decimal years.  I'd like create a line graph that shows the retention rate where the X axis is years and the Y axiz is percent retention.  Essentially, it looks at:

 

count of employees with a tenure value >= value at X axis / total count of records. 

 

Values for this graph might be:

95% retention at 1 year

93% retention at 1.5 years

20% retention at 12.5 years, etc.

 

I imagine it will look something like this (with one line):

 

Image result for retention graph

 

Since I couldn't figure out how to attach data, here's a small dummy version of the dataset:

 

EmployeeTenure
21800.9
25891.81
24891.9
22331.97
23232.15
20612.57
24634.92
29647.95
24819.07
268211.68
289412.92
294713.01
291914.4
291214.45
279231.79
280537.1
278237.51
1 ACCEPTED SOLUTION

First add a column to create year for each employee based on tenure:

 

Year = var x =  FLOOR(Table1[Tenure],1) return if(x>12,12,x)

add measure for total employee count

 

Total Emp = CALCULATE(COUNT(Table1[Employee]), ALL(Table1))

add measure for running total 

 

Running Total = CALCULATE(COUNT(Table1[Employee]), Filter(ALL(Table1), Table1[Year]>=MAX(Table1[Year]))) 

add measure for retention %

 

Retention = DIVIDE([Running Total], [Total Emp], 0)

drop line visual wit year on x axis and retention on values.

 

Change retention measure format to %

 

Although these measures can be done in one measure, but I like to keep it seperate for simplicty and also  can be reused in other areas as well.

 

This is all for reference, you can change calc as you see fit.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

11 REPLIES 11
parry2k
Super User
Super User

does this look right from the sample data you shared, if yes, then i will share the solution

 

tenure.PNG



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Unfortunately, no.  At year 0, retention should be 100%.  With these data, at year 1 value should be 94%, at year 2, 76%.

 

Though, having written that, I may now have an idea on how to solve.

tenure.PNGi guess like this @rouxknee



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Very close - the line looks correct!

 

The values on the line correspond to year 1, year 2, etc. rather than year 2, year 4 (as displayed).

 

 

it is based on a calculated field, so i just created gap of 2 year, can be easily moved to each year. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Great! What's the solution?

First add a column to create year for each employee based on tenure:

 

Year = var x =  FLOOR(Table1[Tenure],1) return if(x>12,12,x)

add measure for total employee count

 

Total Emp = CALCULATE(COUNT(Table1[Employee]), ALL(Table1))

add measure for running total 

 

Running Total = CALCULATE(COUNT(Table1[Employee]), Filter(ALL(Table1), Table1[Year]>=MAX(Table1[Year]))) 

add measure for retention %

 

Retention = DIVIDE([Running Total], [Total Emp], 0)

drop line visual wit year on x axis and retention on values.

 

Change retention measure format to %

 

Although these measures can be done in one measure, but I like to keep it seperate for simplicty and also  can be reused in other areas as well.

 

This is all for reference, you can change calc as you see fit.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you for this, @parry2k - it worked.

 

I'd like to go a little deeper and maybe you can help me.  I have another field - "Veteran Status" - that has values of "Veteran" and "Not a Veteran," how do I create individual lines for each of those values? 

 

I tried using a slicer and using "Veteran Status" in legend, but both ways, the lines that are given just show each group within the context of the whole dataset.  That is, I need a line for each status that ignores everything in the other status.

 

I need to do this for a number of different fields, so anything dynamic that can will change the line by using slicers (as opposed to sets of calculated measures for each group) would be most helpful.

Put that field on legend and see if works

 

make sure your value section has only one field.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

See previous post - putting it on legend only shows the value for that group as they relate to the whole dataset - I need it to show in the context of *only* that group.

 

Ideally, I'd like to show the individual lines on the same graph - that is, show the curves of retention rate for veterans vs. non-veterans.

Deleted a post - understood that first item was a column, not a measure.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.