Forum Discussion
TRICKY DAX Calculated Column Measures
- 6 years ago
Hey Anonymous , I received a request regarding confidence intervals with Kaplan Meier survival curves from Anonymous and so I was working on it and came up with the following answer:
OK, following along from this:
And if you are following my article here:
Then in your KMDeptDaysAll table, create this measure:
ci_alpha = 0.05
This is your confidence interval, in this case 95%
And then create these columns:
ci_S(t) = VAR __table = FILTER(ALL(KMDeptDaysAll),[Department] = EARLIER([Department]) && [Days] <= EARLIER([Days])) RETURN PRODUCTX(__table,[1-e_i/d_i]) ci_se_1 = VAR __calc = [e_i] / ([d_i] * ([d_i] - [e_i])) RETURN IF(ISERROR(SQRT(__calc)),BLANK(),[ci_S(t)] * SQRT(__calc)) ci_se = VAR __table = FILTER(ALL(KMDeptDaysAll),[Department] = EARLIER([Department]) && [Days] <= EARLIER([Days])) VAR __sum = SUMX(__table,[ci_se_1]) RETURN [ci_S(t)] * __sum ci_lower = [ci_S(t)] ^ IF(ISERROR(EXP(NORM.S.INV([ci_alpha]/2)/IF(ISERROR(LN([ci_S(t)])),BLANK(),LN([ci_S(t)])*[ci_se]/[ci_S(t)]))),BLANK(),EXP(NORM.S.INV([ci_alpha]/2)/IF(ISERROR(LN([ci_S(t)])),BLANK(),LN([ci_S(t)])*[ci_se]/[ci_S(t)]))) ci_upper = [ci_S(t)] ^ IF(ISERROR(EXP(-NORM.S.INV([ci_alpha]/2)/IF(ISERROR(LN([ci_S(t)])),BLANK(),LN([ci_S(t)])*[ci_se]/[ci_S(t)]))),BLANK(),EXP(-NORM.S.INV([ci_alpha]/2)/IF(ISERROR(LN([ci_S(t)])),BLANK(),LN([ci_S(t)])*[ci_se]/[ci_S(t)])))
Can't be certain this is all 100% correct as the original article I was working from didn't have confidence intervals. Will try to do some verification work on this.
Hey Anonymous , I received a request regarding confidence intervals with Kaplan Meier survival curves from Anonymous and so I was working on it and came up with the following answer:
OK, following along from this:
And if you are following my article here:
Then in your KMDeptDaysAll table, create this measure:
ci_alpha = 0.05
This is your confidence interval, in this case 95%
And then create these columns:
ci_S(t) = VAR __table = FILTER(ALL(KMDeptDaysAll),[Department] = EARLIER([Department]) && [Days] <= EARLIER([Days])) RETURN PRODUCTX(__table,[1-e_i/d_i]) ci_se_1 = VAR __calc = [e_i] / ([d_i] * ([d_i] - [e_i])) RETURN IF(ISERROR(SQRT(__calc)),BLANK(),[ci_S(t)] * SQRT(__calc)) ci_se = VAR __table = FILTER(ALL(KMDeptDaysAll),[Department] = EARLIER([Department]) && [Days] <= EARLIER([Days])) VAR __sum = SUMX(__table,[ci_se_1]) RETURN [ci_S(t)] * __sum ci_lower = [ci_S(t)] ^ IF(ISERROR(EXP(NORM.S.INV([ci_alpha]/2)/IF(ISERROR(LN([ci_S(t)])),BLANK(),LN([ci_S(t)])*[ci_se]/[ci_S(t)]))),BLANK(),EXP(NORM.S.INV([ci_alpha]/2)/IF(ISERROR(LN([ci_S(t)])),BLANK(),LN([ci_S(t)])*[ci_se]/[ci_S(t)]))) ci_upper = [ci_S(t)] ^ IF(ISERROR(EXP(-NORM.S.INV([ci_alpha]/2)/IF(ISERROR(LN([ci_S(t)])),BLANK(),LN([ci_S(t)])*[ci_se]/[ci_S(t)]))),BLANK(),EXP(-NORM.S.INV([ci_alpha]/2)/IF(ISERROR(LN([ci_S(t)])),BLANK(),LN([ci_S(t)])*[ci_se]/[ci_S(t)])))
Can't be certain this is all 100% correct as the original article I was working from didn't have confidence intervals. Will try to do some verification work on this.