Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Kaplan Meier Estimator with a second dimension

Hi everyone,

I succeed to implement the Kaplan Meier estimator inside a line chart in Qlik Sense like this

kaplan.png

To do that, I write this expression which is the exact transcription of KM Estimator

= if(RowNo() = 1, 1,
  (1 - (count({<Analyse_Type = {'Churn'}>}%Key_Contract) /
  count({<Analyse_Type = {'Parc'}>}%Key_Contract))) * above(Column(1))
)

Everything works fine but I'd like to add a second dimension in the graph and when I do that, the recursive above seems to get muddle up. I try to aggregate the above by my second dimension but it is not working.

Does someone have an idea to do that? Or another way to write the Kaplan Meier estimator without the using of a recursion?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi Peter,

Thanks a lot for your answer.

Good to know about the TOTAL inside sibling functions but I tried your solution and here's what I get:

kaplan2.png

Seems like the above function does not work anymore.

Have you an idea why this does not work?

Edit:

I find a solution to my issue. I switch the way to make a accumulation of product (the recursive above) by the mathematical logic
exp(rangeSum(log())). I aggregate the rangeSum by my second dimension ordered by my first dimension (the interval) and everything works fine.

Here the final expression of the Kaplan Meier Estimator:

exp(aggr(Rangesum(Above(log(fabs(

(1 - (count({<Analyse_Type = {'Churn'}>}%Key_Contract) / count({<Analyse_Type = {'SurvivalParc'}>}%Key_Contract)))) ),0, Rowno()))

, REGION, (Delivered_Days_5, NUMERIC, ASCENDING)))

and here is the visual result:

kaplan3.png

Thank you for your help.

View solution in original post

2 Replies
petter
Partner - Champion III
Partner - Champion III

When you have more than one dimension you often have to have a TOTAL in the Above() function (or any of it's sibling functions that belong to the inter-record functions). Similarly the RowNo() function also needs a TOTAL ...

So maybe this will work:


if(RowNo(TOTAL) = 1, 1, 

  (1 - (count({<Analyse_Type = {'Churn'}>}%Key_Contract) / 

  count({<Analyse_Type = {'Parc'}>}%Key_Contract))) * Above(TOTAL Column(1))

)

Anonymous
Not applicable
Author

Hi Peter,

Thanks a lot for your answer.

Good to know about the TOTAL inside sibling functions but I tried your solution and here's what I get:

kaplan2.png

Seems like the above function does not work anymore.

Have you an idea why this does not work?

Edit:

I find a solution to my issue. I switch the way to make a accumulation of product (the recursive above) by the mathematical logic
exp(rangeSum(log())). I aggregate the rangeSum by my second dimension ordered by my first dimension (the interval) and everything works fine.

Here the final expression of the Kaplan Meier Estimator:

exp(aggr(Rangesum(Above(log(fabs(

(1 - (count({<Analyse_Type = {'Churn'}>}%Key_Contract) / count({<Analyse_Type = {'SurvivalParc'}>}%Key_Contract)))) ),0, Rowno()))

, REGION, (Delivered_Days_5, NUMERIC, ASCENDING)))

and here is the visual result:

kaplan3.png

Thank you for your help.