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

Reset running total by column value and calculated for group

Hi guys, 

 

i have a running total of a sales column. This running total shall start to cumulate sales from 0 after the columnes where the reset column is 1. The whole cumulation should be done by group for the SKU column:


Here the example with the yellow colum as output target:
Reset Running Total.JPG
Anybody any i dea?

Thanks in advance!

1 ACCEPTED SOLUTION

I gave you the measure version.  Here is the modified version that should work in a calculated column.

 

RT Since Reset =
VAR thisdate =  Reset[Date]
VAR thissku = Reset[SKU] 
VAR lastresetdate =
    CALCULATE (
        MAX ( Reset[Date] ),
ALL(Reset),        

Reset[SKU] = thissku,
        Reset[Date] <= thisdate,
        Reset[Reset] = 1
    )
VAR result =
    CALCULATE (
        SUM ( Reset[Sales] ),
        ALL ( Reset ),
        Reset[SKU] = thissku,
        FILTER (
            ALL ( Reset[Date] ),
            Reset[Date] >= lastresetdate
                && Reset[Date] <= thisdate
        )
    )
RETURN
    result

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please try the below for creating a new column.

 

Sales Cumulate Reset CC =
VAR resetcumulate =
CALCULATE (
SUM ( 'Table'[Reset] ),
FILTER (
'Table',
EARLIER ( 'Table'[Date] ) >= 'Table'[Date]
&& EARLIER ( 'Table'[SKU] ) = 'Table'[SKU]
)
)
VAR currentdate = 'Table'[Date]
VAR resetcumulatetable =
FILTER (
ADDCOLUMNS (
SUMMARIZE ( 'Table', 'Table'[Date], 'Table'[SKU], 'Table'[Sales] ),
"@resetgroup",
CALCULATE (
SUM ( 'Table'[Reset] ),
FILTER (
'Table',
EARLIER ( 'Table'[Date] ) >= 'Table'[Date]
&& EARLIER ( 'Table'[SKU] ) = 'Table'[SKU]
)
)
),
[@resetgroup] = resetcumulate
&& 'Table'[Date] <= currentdate
&& EARLIER ( 'Table'[SKU] ) = 'Table'[SKU]
)
RETURN
SUMX ( resetcumulatetable, 'Table'[Sales] )

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
parry2k
Super User
Super User

@Anonymous just curious how come row 6 and 11 has a value of 2, isn't it should be 1 since it is reset at the previous date?



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.

mahoneypat
Microsoft Employee
Microsoft Employee

Here is one measure expression that returns your desired results.

 

RT Since Reset =
VAR thisdate =
    MAX ( Reset[Date] )
VAR thissku =
    MIN ( Reset[SKU] )
VAR lastresetdate =
    CALCULATE (
        MAX ( Reset[Date] ),
        ALL ( Reset ),
        Reset[SKU] = thissku,
        Reset[Date] <= thisdate,
        Reset[Reset] = 1
    )
VAR result =
    CALCULATE (
        SUM ( Reset[Sales] ),
        ALL ( Reset ),
        Reset[SKU] = thissku,
        FILTER (
            ALL ( Reset[Date] ),
            Reset[Date] >= lastresetdate
                && Reset[Date] <= thisdate
        )
    )
RETURN
    result

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

@mahoneypat thank you for the quick reply. But the query gives the same value in al columns.

Unbenannt.JPG

I gave you the measure version.  Here is the modified version that should work in a calculated column.

 

RT Since Reset =
VAR thisdate =  Reset[Date]
VAR thissku = Reset[SKU] 
VAR lastresetdate =
    CALCULATE (
        MAX ( Reset[Date] ),
ALL(Reset),        

Reset[SKU] = thissku,
        Reset[Date] <= thisdate,
        Reset[Reset] = 1
    )
VAR result =
    CALCULATE (
        SUM ( Reset[Sales] ),
        ALL ( Reset ),
        Reset[SKU] = thissku,
        FILTER (
            ALL ( Reset[Date] ),
            Reset[Date] >= lastresetdate
                && Reset[Date] <= thisdate
        )
    )
RETURN
    result

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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