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.
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):
Since I couldn't figure out how to attach data, here's a small dummy version of the dataset:
Employee | Tenure |
2180 | 0.9 |
2589 | 1.81 |
2489 | 1.9 |
2233 | 1.97 |
2323 | 2.15 |
2061 | 2.57 |
2463 | 4.92 |
2964 | 7.95 |
2481 | 9.07 |
2682 | 11.68 |
2894 | 12.92 |
2947 | 13.01 |
2919 | 14.4 |
2912 | 14.45 |
2792 | 31.79 |
2805 | 37.1 |
2782 | 37.51 |
Solved! Go to 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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
95 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |