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
Ashoop2020
Frequent Visitor

Running Total with a Reset

Hello! I need to create a running total column for the Print Drop Factor column that resets when the Print Circ column is greater than zero. Here is my sample data below: 

Screenshot 2022-12-05 085026.png

 Thank you!

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Ashoop2020 ;

You could add index column first.

vyalanwumsft_0-1670306390292.png

Then add custom column.

=List.Accumulate(List.FirstN( #"Added Index"[Print Drop Factor],[Index]),0,(state,current)
=> if current=0 then 0 else state + current
)

Delete index column.

The final result:

vyalanwumsft_1-1670306462082.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1SGONMArgouNlYwFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Print Drop Factor " = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Print Drop Factor ", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Print Drop Factor ", "Print Drop Factor"}}),
    #"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each 
List.Accumulate(List.FirstN( #"Added Index"[Print Drop Factor],[Index]),0,(state,current)
=> if current=0 then 0 else state + current
)),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
    #"Removed Columns"


Best Regards,
Community Support Team _ Yalan Wu
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

2 REPLIES 2
Ashoop2020
Frequent Visitor

@v-yalanwu-msft It worked great thanks for the help!

v-yalanwu-msft
Community Support
Community Support

Hi, @Ashoop2020 ;

You could add index column first.

vyalanwumsft_0-1670306390292.png

Then add custom column.

=List.Accumulate(List.FirstN( #"Added Index"[Print Drop Factor],[Index]),0,(state,current)
=> if current=0 then 0 else state + current
)

Delete index column.

The final result:

vyalanwumsft_1-1670306462082.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1SGONMArgouNlYwFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Print Drop Factor " = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Print Drop Factor ", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Print Drop Factor ", "Print Drop Factor"}}),
    #"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each 
List.Accumulate(List.FirstN( #"Added Index"[Print Drop Factor],[Index]),0,(state,current)
=> if current=0 then 0 else state + current
)),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
    #"Removed Columns"


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Top Solution Authors