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
Anonymous
Not applicable

SUM function

Hi, I'm confused by SUM/SUMX formulas. I want to create a column called Total Time that:

- has 0 in the first row

- starting from the second row down every cell is a sum of a current value from a column called time and all the values from the rows above.

Easily done in Excel (=A2+B2), but can get it right in powerbi.

 

1.PNG

12 REPLIES 12
v-lili6-msft
Community Support
Community Support

hi @Anonymous 

For your case, you need to add an index column first, then create a new column as below:

Total time, hrs = CALCULATE(SUM('Table'[time, hrs]),FILTER('Table','Table'[Index]<EARLIER('Table'[Index])))+0

Result:

3.JPG

 

And if you want show 191, that needs you create a measure to show it in visual, try this way as below:

Step1:

Add  Index table as below:

Index table = GENERATESERIES(1,MAX('Table'[Index])+1,1)

Step2:

Create a relationship by index column as below:

4.JPG

 

Step3:

Create a measure as below:

Total time, hrs = CALCULATE(SUM('Table'[time, hrs]),FILTER(ALL('Index table'),'Index table'[Index]<MAX('Index table'[Index])))+0

Result:

5.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-lili6-msft thanks for that! 

I've forgot to add a column called step_no. 

There is one problem, this measure adds new rows:

 

1.PNG

 

Original table visualization (target_duration is the time column in my post):

2.PNG

After adding the measure:

3.PNG

hi  @Anonymous 

Could you please share your sample pbix file for us have a test? I will help you adjust it quickly.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , You have add an index column

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

Cumm = CALCULATE(SUM(Table[time hrs]),filter(all(Table),Table[index] <=maxx(Table,Table[index])))

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
Anonymous
Not applicable

Hi @amitchandak  thanks for that! 

I've forgot to add a column called step_no. 

There is one problem, this measure/column adds new rows:

 

1.PNG

 

Original table visualization (target_duration is the time column in my post):

2.PNG

After adding the measure:

3.PNG

@Anonymous , Just check in visual table, does target duration has an aggregation, seem like do not summarize option on that. If so make it Sum.

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
Anonymous
Not applicable

@amitchandak changed it to Sum. The same result. 

Anonymous
Not applicable

@amitchandak can I create an index column that copies the column step no? If i just add the index column (from 1), the order is different from the order in step no

FrankAT
Community Champion
Community Champion

Hi @Anonymous,

you are looking for the running total. You can accomplish it as follows (see figure):

 

25-06-_2020_16-28-12.jpg

 

Regards FrankAT

Anonymous
Not applicable

@FrankAT thank you! but is there a formula that can both add a row with 0 and then the running total, so it'd look like on the screenshot?

parry2k
Super User
Super User

@Anonymous now for running total, you have to have a column that defines the order in which you want to sum this running total, that column can be a date or index columns. Do you have something like that in your model? if not then add an index column in power query and then running total can be created.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k yes, I do. it's called Step No:

Capture.PNG

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 Kudoed Authors