Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Interaction between several measures filter context

Hello, 

 

I am trying to built a dynamic kaplan meier indicateur without create a physical table as it was done here https://community.powerbi.com/t5/Desktop/Kaplan-Meier-Survival-Curves/m-p/330081

 

To do that, I split each step of calculation and plot them into power visual frame, here below :

 

Ron33_1-1631785597285.png

 

 

All the columns are calculatued measures except "IndiceTemps" that is a column from the original table. 

 

Almost all the measures calculated returned me the result I expected except the measure "SumLnKaplanMeier".

I have just tried to calculate a running sum of LnKaplanMeier, but something is going wrong.

The values  I expected to have for that measure in this views are successively : -0.03 ; -0.07 ;  -0.11 ; -0.17 ; -0.23 ...

 

Here the formula for each one:

 

SumCount = CALCULATE(SUM(reporting_courbe_de_survie_contrat[Count]), ALLEXCEPT(reporting_courbe_de_survie_contrat, reporting_courbe_de_survie_contrat[IndiceTemps]))
 
RunningCount =
CALCULATE(
    [SumCount],
    FILTER(
        ALLSELECTED('reporting_courbe_de_survie_contrat'[IndiceTemps]),
        ISONORAFTER('reporting_courbe_de_survie_contrat'[IndiceTemps], MAX('reporting_courbe_de_survie_contrat'[IndiceTemps]), DESC)
    )
)
 
SumResilie = CALCULATE(SUM(reporting_courbe_de_survie_contrat[resiliation]), ALLEXCEPT(reporting_courbe_de_survie_contrat, reporting_courbe_de_survie_contrat[IndiceTemps]))
 
n_risk = CALCULATE(SUM(reporting_courbe_de_survie_contrat[Count]), ALLSELECTED(reporting_courbe_de_survie_contrat[IndiceTemps])) + [SumCount] - [RunningCount]
 
KaplanMeier = 1 - [SumResilie]/[n_risk]
 
LnKaplanMeier = LN([KaplanMeier])
 

 

SumLnKaplanMeier =
CALCULATE(
    [LnKaplanMeier],
    FILTER(
        ALLSELECTED(reporting_courbe_de_survie_contrat[IndiceTemps]),
        ISONORAFTER(reporting_courbe_de_survie_contrat[IndiceTemps], MAX(reporting_courbe_de_survie_contrat[IndiceTemps]), DESC)
    )
)
 
Taux_De_Survie = EXP([SumLnKaplanMeier])
 
 
I think that the issue comes from an incompatibility between the filters context. 
 
Thank you for helping to solve this.
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous 

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Anonymous ,

 

Has you referred this is a question about context, since you are not making the selection of the energie and energie type on your calculation the context get's missed and the sum is made for all IndiceTemps.

 

1_SumLnKaplanMeier = SUMX (
        FILTER (
            SUMMARIZE (
                ALLSELECTED ( reporting_courbe_de_survie_contrat_test ),
                reporting_courbe_de_survie_contrat_test[1_IndiceTemps],
                reporting_courbe_de_survie_contrat_test[energie],
                reporting_courbe_de_survie_contrat_test[type_energie],
                "@KaplanMeier", [1_LnKaplanMeier]
            ),
            reporting_courbe_de_survie_contrat_test[1_IndiceTemps]
                <= MAX ( reporting_courbe_de_survie_contrat_test[1_IndiceTemps] )
                && reporting_courbe_de_survie_contrat_test[energie]
                    = MAX ( reporting_courbe_de_survie_contrat_test[energie] )
                && reporting_courbe_de_survie_contrat_test[type_energie]
                    = MAX ( reporting_courbe_de_survie_contrat_test[type_energie] )
        ),
        [@KaplanMeier]
    )

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix
Super User
Super User

Hi @Anonymous 

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.