SURVIVAL.AT OpenBI
A Kaplan-Meier curve's value at a time, for a sentence or a card.
Group: Survival analysis. OpenBI’s own: DAX has no function of this name.
Syntax
SURVIVAL.AT ( <table>, <duration>, <event>, <time> )
| Parameter | Type | Description |
|---|---|---|
table | Table | The rows to follow, one a subject such as a customer, a policy or a machine: a table of the model or a table expression, as the filters leave it. |
duration | Number evaluated for each row | How long each row was followed: until its event, or until we stopped seeing it. In any unit (days, months, years), the same for every row. |
event | Number evaluated for each row | 1 or TRUE when the row's duration ended in the event (the customer left); 0 or FALSE when it did not, so all we know is that it lasted at least that long (censored). |
time | Number | The time to read the curve at. |
Returns
Number. The Kaplan-Meier survival at that time: the share still without the event.
Remarks
- It is the Survival of
SURVIVAL.CURVEat the last time at or before the one given: events at that very time count. Before the first event it is 1. - One value, for a card or a sentence: "78 % of customers stay a year". For a group, filter the table:
SURVIVAL.AT ( FILTER ( Customers, [Plan] = "Plus" ), [Months], [Left], 12 ). - Rows with a blank duration or a blank event are left out. An event other than 0, 1, TRUE or FALSE is an error.
Compared with DAX
An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.
Examples
The curve at a few times
EVALUATE
VAR Customers =
DATATABLE (
"Plan", STRING, "Months", INTEGER, "Left", INTEGER,
{
{ "Basic", 2, 1 }, { "Basic", 3, 0 }, { "Basic", 5, 1 }, { "Basic", 7, 1 }, { "Basic", 8, 0 },
{ "Plus", 4, 1 }, { "Plus", 9, 0 }, { "Plus", 11, 1 }, { "Plus", 12, 1 }, { "Plus", 15, 0 }
}
)
RETURN
ROW (
"At 0", SURVIVAL.AT ( Customers, [Months], [Left], 0 ),
"At 6", SURVIVAL.AT ( Customers, [Months], [Left], 6 ),
"At 11", SURVIVAL.AT ( Customers, [Months], [Left], 11 ),
"At 100", SURVIVAL.AT ( Customers, [Months], [Left], 100 )
)
| At 0 | At 6 | At 11 | At 100 |
|---|---|---|---|
| 1 | 0.675 | 0.375 | 0.1875 |
Half a year, by plan
EVALUATE
VAR Customers =
DATATABLE (
"Plan", STRING, "Months", INTEGER, "Left", INTEGER,
{
{ "Basic", 2, 1 }, { "Basic", 3, 0 }, { "Basic", 5, 1 }, { "Basic", 7, 1 }, { "Basic", 8, 0 },
{ "Plus", 4, 1 }, { "Plus", 9, 0 }, { "Plus", 11, 1 }, { "Plus", 12, 1 }, { "Plus", 15, 0 }
}
)
RETURN
ROW (
"Basic", SURVIVAL.AT ( FILTER ( Customers, [Plan] = "Basic" ), [Months], [Left], 6 ),
"Plus", SURVIVAL.AT ( FILTER ( Customers, [Plan] = "Plus" ), [Months], [Left], 6 )
)
| Basic | Plus |
|---|---|
| 0.533333333333333 | 0.8 |