OpenBI Docs Buy

SURVIVAL.MEDIAN OpenBI

A Kaplan-Meier curve's median, for a sentence or a card.

Group: Survival analysis. OpenBI’s own: DAX has no function of this name.

Syntax

SURVIVAL.MEDIAN ( <table>, <duration>, <event> )
ParameterTypeDescription
tableTableThe 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.
durationNumber
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.
eventNumber
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).

Returns

Number. The median time to the event on the Kaplan-Meier curve, or BLANK when the curve never falls to a half.

Remarks

  • The median is the earliest time at which the curve has fallen to a half or lower. When the curve sits at exactly a half until its next drop, the median is midway between the two times, as R gives it.
  • When fewer than half the rows have had the event by their last time, the median is not known yet, and the result is BLANK. SURVIVAL.SUMMARY's restricted mean is a figure that always exists.
  • One value, for a card or a sentence. For a group, filter the table first.
  • 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

All customers, and each 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 (
        "All", SURVIVAL.MEDIAN ( Customers, [Months], [Left] ),
        "Basic", SURVIVAL.MEDIAN ( FILTER ( Customers, [Plan] = "Basic" ), [Months], [Left] ),
        "Plus", SURVIVAL.MEDIAN ( FILTER ( Customers, [Plan] = "Plus" ), [Months], [Left] )
    )
AllBasicPlus
11712

Not known yet

One of three left, and the curve never gets to a half.

EVALUATE
VAR Customers = DATATABLE ( "Months", INTEGER, "Left", INTEGER, { { 2, 1 }, { 3, 0 }, { 5, 0 } } )
RETURN
    ROW ( "Median", SURVIVAL.MEDIAN ( Customers, [Months], [Left] ) )
Median
(blank)

Exactly a half

The curve is at a half from month 4 to its next drop at month 8: the median is 6.

EVALUATE
VAR Customers =
    DATATABLE ( "Months", INTEGER, "Left", INTEGER, { { 2, 1 }, { 4, 1 }, { 6, 0 }, { 8, 1 } } )
RETURN
    ROW ( "Median", SURVIVAL.MEDIAN ( Customers, [Months], [Left] ) )
Median
6

SURVIVAL.AT, SURVIVAL.SUMMARY, SURVIVAL.CURVE.

Last updated · OpenBI Studio 0.3.74