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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
GeeWhiz7
Regular Visitor

Cumulative Sum by Group Issue

Hi,
I'm new to Power BI having come over from the Spotfire world.

I have two tables (Main) and (Manufacturing) inside the PBIX file.

 

https://drive.google.com/file/d/1nsB9aREHu_007VNNZW6jBHXSnSuF5jnG/view?usp=share_link


I would like to, compute a simple running total/cumulative new column using Rate and Date and grouped by ID to end up with a table like the picture shown.

I've tried a few ways, but can't get a proper result and right now just get the Total of each Group (Name) as a single value (202+338+174=604). The "Excel Run Total" column in the manufacturing table shows what I want to achieve, but I want to do it in Power BI. Clearly I'm missing something, but here is the syntax I'm using.

 

PBI Run Total =
VAR MaxDate = MAX('Manufacturing'[Date])
RETURN
CALCULATE(
SUM(Manufacturing[Rate]),
FILTER(
ALLSELECTED(Manufacturing),
'Manufacturing'[Date]<=MaxDate
)
)

Thanks for your help!

 

GeeWhiz7_1-1668736864389.png

 

 



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @GeeWhiz7 ,

I have created a simple sample, please refer to it to see if it helps you.

Create a column.

PBI Run Total = 
CALCULATE(SUM(Manufacturing[Rate]),FILTER(Manufacturing,Manufacturing[ID]=EARLIER(Manufacturing[ID])&&Manufacturing[Date]<=EARLIER(Manufacturing[Date])))

Or a measure.

Measure =
 CALCULATE(SUM(Manufacturing[Rate]),FILTER(ALL(Manufacturing),Manufacturing[ID]=SELECTEDVALUE(Manufacturing[ID])&&Manufacturing[Date]<=SELECTEDVALUE(Manufacturing[Date])))

vpollymsft_0-1668995049300.png

If I have misunderstood your meaning, please provide your desired output with more details.

 

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @GeeWhiz7 ,

I have created a simple sample, please refer to it to see if it helps you.

Create a column.

PBI Run Total = 
CALCULATE(SUM(Manufacturing[Rate]),FILTER(Manufacturing,Manufacturing[ID]=EARLIER(Manufacturing[ID])&&Manufacturing[Date]<=EARLIER(Manufacturing[Date])))

Or a measure.

Measure =
 CALCULATE(SUM(Manufacturing[Rate]),FILTER(ALL(Manufacturing),Manufacturing[ID]=SELECTEDVALUE(Manufacturing[ID])&&Manufacturing[Date]<=SELECTEDVALUE(Manufacturing[Date])))

vpollymsft_0-1668995049300.png

If I have misunderstood your meaning, please provide your desired output with more details.

 

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you to each person providing a solution as it helps me better understand the syntax.  I think the easiest one for me to use was the v-polly-msft solution mainly because it is explicit in what it is filtering (manufacturing ID and date columns) but now I understand how to make each work.

amitchandak
Super User
Super User

@GeeWhiz7 , Always use a separate date table in such cases , joined with date of date of your table

 

PBI Run Total =
VAR MaxDate = MAX('Date'[Date])
RETURN
CALCULATE(
SUM(Manufacturing[Rate]),
FILTER(
ALLSELECTED(Date),
'Date'[Date]<=MaxDate
)
)

 

Running Total/ Cumulative: https://www.youtube.com/watch?v=h2wsO332LUo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=41

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

thank you for looking at this amitchandak.

I watched the video and created a separate Date Table with unique Date Values and then modified the syntax to below, but now I only get a repeat of the rate from the Manufacturing table.

 

I read this as,

  • declare var and assign the max date from date table to var
  • calculate the sum of rate from the manufacturing table filtered for all selected dates in the date table where those dates are less than the max variable.

Not sure what I'm not understanding

 

GeeWhiz7_0-1668782005268.png

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.