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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
attempt1
Frequent Visitor

Issue with Cumulative Sum Measure

Hello,

 

My measure to calculate the cumulative sum of rows (excluding rows where the 'End' column date has past) is not working as intended in my stacked column chart when no slicer filter is selected.

The y-axis of my stacked column chart uses this measure:

 

all_data_cumulative =
CALCULATE(
COUNTROWS('all_data'),
FILTER(
ALLSELECTED('all_data'),
'all_data'[Start] <= MAX('date_table'[Date]) &&
'all_data'[End] > MAX('date_table'[Date]) &&
('all_data'[Type] = SELECTEDVALUE('all_data'[Type], 'all_data'[Type]))
)
)

 

The x-axis of the chart is a 'Date' column from the 'date_table' (the date table), while the Legend is based on the 'Type' column from the 'all_data' table. My dashboard also incorporates a slicer with the 'Type' field (from 'all_data' table) with the options 'Cars' and 'Trucks'.

Everything works perfectly when either 'Cars' or 'Trucks' is selected in the slicer. (Screenshots below)

attempt1_1-1728876131378.png

attempt1_2-1728876150886.png

 

However when neither 'Type' is selected, both types y-axis values are added together for each 'Type' which is not intended after no 'Start' dates occur (2025 in this case) screenshot below

attempt1_3-1728876183825.png


My goal is for each 'Type' bar to reflect the all_data_cumulative measure solely for that type. Similar to below:

attempt1_4-1728876571313.png

Also, a relationship exists between the 'Start' column of the 'all_data' table and the 'Date' column of the 'date_table' with a "many-to-one" relationship defined. Also, the columns 'Start', 'End', and 'Date' are all of Date type.
Thank you

1 ACCEPTED SOLUTION

Hi @attempt1 ,

try this:

 

 

all_data_cumulative = 

VAR _CurrDate = MAX('date_table'[Date])

RETURN

CALCULATE(
    COUNTROWS('all_data'),
    KEEPFILTERS(
        'all_data'[Start] <= _CurrDate &&
        'all_data'[End] > _CurrDate
    ),
    ALLSELECTED(date_table)
)

 

This may be your expected output:

hnguy71_0-1728943476205.png

 

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

4 REPLIES 4
attempt1
Frequent Visitor

Hi @attempt1 ,

try this:

 

 

all_data_cumulative = 

VAR _CurrDate = MAX('date_table'[Date])

RETURN

CALCULATE(
    COUNTROWS('all_data'),
    KEEPFILTERS(
        'all_data'[Start] <= _CurrDate &&
        'all_data'[End] > _CurrDate
    ),
    ALLSELECTED(date_table)
)

 

This may be your expected output:

hnguy71_0-1728943476205.png

 

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Yes, thank you so much @hnguy71 , exactly what I wanted.

Ritaf1983
Super User
Super User

Hi @attempt1 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.