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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BenFransen
Advocate II
Advocate II

Dynamic line chart for CUSUM analysis

I'm wondering how I can make a dynamic line chart. The goal I'm trying to achieve is to create a CUSUM chart. In hospital care this is used to plot a trend line on how you're doing regarding mortality versus the calculated risk a patient could die during surgery. The formula is very easy: starting at 0, for each event add the the risk score (percentage) a patient could die if the patient didn't die during hospital admission or substract that same value if the patient did die.

 

For example this could be the data (where CUSUMValue needs to be calculated on the fly)

 

EventID  RiskScore, PatientDied  CUSUMValue

1, 8, False, 8

2, 4, False, 12

3, 5, False, 17

4, 29, True, -12

5, 9.4, False, -2.6

 

In my case of course I have a date column as well and the dataset contains data of the last 12 months including all data from the current month. Using DAX I can calculate the CUSUMValue (I think) but how can this be done dynamically? I want the chart to update when I filter through months but it always has to start from 0 and count forwards from there to the end of the selected data.

 

Is this possible in the current version in PowerBI?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @BenFransen,

 

According to your description, you want to calculate dynamic value which based on "RiskScore" and "PatientDied" columns, right?

 

If that is a case, you can refer to belwo sample:

 

Measures:

 

CurrentValue =
var currPatientDied= LASTNONBLANK(Sheet2[PatientDied],[PatientDied])
Return
Max([RiskScore])*SWITCH(currPatientDied,FALSE(),1,TRUE(),-1)

 

CUSUMValue =
SUMX(FILTER(ALL(Sheet2),Sheet2[EventID]<=MAX([EventID])),[CurrentValue])

 

Create line chart:

Capture.PNG

 

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @BenFransen,

 

According to your description, you want to calculate dynamic value which based on "RiskScore" and "PatientDied" columns, right?

 

If that is a case, you can refer to belwo sample:

 

Measures:

 

CurrentValue =
var currPatientDied= LASTNONBLANK(Sheet2[PatientDied],[PatientDied])
Return
Max([RiskScore])*SWITCH(currPatientDied,FALSE(),1,TRUE(),-1)

 

CUSUMValue =
SUMX(FILTER(ALL(Sheet2),Sheet2[EventID]<=MAX([EventID])),[CurrentValue])

 

Create line chart:

Capture.PNG

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors