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.
does this look right from the sample data you shared, if yes, then i will share the solution
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.
i 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.
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 |
---|---|
107 | |
99 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |