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.
@Buzzshot43 posted a question on KM Survival Curves here:
https://community.powerbi.com/t5/Desktop/KM-Survival-Curve-in-Power-BI/m-p/326809#M145836
The post refers to the following Tableau article:
https://www.linkedin.com/pulse/survival-curves-tableau-hr-data-chris-short/
So, figured I'd give it a shot and have gotten part of the way there but was hoping the community could help me finish this off.
I am using the dataset from the Tableau article referenced above and am trying to recreate this using pure Power BI (no R). I imported the data as HRData. The data looks like:
ID,Name,Hire Date,Termination Date,Status,Department
1,Inez Laurie,4/23/2010,9/2/2015,Inactive,HR
2,Yasuko Scruton,1/20/2010,,Active,Sales
...
So, in the dataset, I created the following custom columns:
Years = IF([Status]="Active",DATEDIFF(HRData[Hire Date],TODAY(),YEAR),DATEDIFF(HRData[Hire Date],HRData[Termination Date],YEAR)) Event = IF(HRData[Status] = "Inactive",1,0) Count = 1
I created a Calendar table using
Calendar = CALENDARAUTO(12)
Which I tied to Termination Date (relationship)
I created a measure to give me a running total for Count:
Count running total in Date = CALCULATE( SUM('HRData'[Count]), FILTER( ALLSELECTED('Calendar'[Date]), ISONORAFTER('Calendar'[Date], MAX('Calendar'[Date]), DESC) ) )
I created a measure for d_i:
d_i = SUM(HRData[Event])
I created a measure for n_i
n_i = COUNTROWS(HRData) + CALCULATE(COUNTROWS(HRData),ALL(HRData)) - [Count running total in Date]
This is where things get a little messy. The formula for KM goes something like:
(Previous Value of KM) * (1-d_i/n_i)
So, what I did was create three measures like this:
KM1 = 1-[d_i]/[n_i] KM-1 = CALCULATE([KM1],DATEADD('Calendar'[Date],-1,DAY)) KM = [KM-1]*[KM1]
The thought here was that I could have a continuous line chart by [Date] in Calendar and calculate KM1 for that date, KM1 for the previous date (KM-1) and then use those to calculate KM.
But, I'm not really getting what I expected and was wondering if someone could take a look and see if they can get this to work or have a better way.
Solved! Go to Solution.
Full solution posted here:
https://www.linkedin.com/pulse/kaplan-meier-survival-curves-power-bi-greg-deckler-microsoft-mvp-
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 |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |