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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Running total with Reset

Hi there,

 

I am trying to create a column that has a running total, but resets if a column has a 1 (if the column has a value of 0, then the score does not reset). I followed this previous post, but I am getting something odd. 

https://community.powerbi.com/t5/Desktop/Running-Total-Reset-based-on-Column-Attribute/m-p/251130

 

The actual line items with dates show the correct running total (with reset). however, the dates that do not have activities show a value of 1090 (which happens to be the running total on 7/29/19). 

For example, based on the data table below, Dates of 12/31/18 to 1/22/19 show a value of 1090, which causes my line chart to be incorrect. 

 

The sample data set is below. What happens is that I choose a single customer id, and have a list of all the activities that the customer had on our website. Each activity is assigned a specific score and these scores are aggregated until they need to be reset, which is denoted by the "Reset score" column (1=reset, 2=no reset).  The "Running score with reset" is what I'm trying to get, but I'm getting scores of 1090 for all the dates that are not listed in the table. . 

 

Here are the calculations I am using:

 

Running Score =
CALCULATE(
sum(Table1'[Activity Score]),
FILTER(
ALLSELECTED(Table1),
Table1[Activity Date] <= max(Table1[Activity Date])))

 

Max Date = maxx(
FILTER(
ALLSELECTED(Table1),
Table1[reset lead score] = 1 && Table1[Activity Date] <= max(Table1[Activity Date])),
Table1[Activity Date])

 

Running Score with Reset =
CALCULATE(
sum(Table1[Activity Score]),
DATESBETWEEN(
Table1[Activity Date],'Measure Table'[Max Date],LASTDATE(Table1'[Activity Date])))

 

Data set:

IdID IndexActivity DateActivity ScoreRunning Scorereset scoreMax DateRunning score with reset
N0EAJ112/30/20185070112/30/201870
N0EAJ212/30/20182070012/30/201870
N0EAJ31/23/20195012011/23/201950
N0EAJ41/24/20195022001/23/2019100
N0EAJ51/24/20195022001/23/2019150
N0EAJ62/12/20195027012/12/201950
N0EAJ72/17/20195039012/17/2019120
N0EAJ82/17/20195039002/17/2019120
N0EAJ92/17/20192039002/17/2019120
N0EAJ102/26/20195049012/26/2019100
N0EAJ112/26/20195049002/26/2019100
N0EAJ123/5/20195054013/5/201950
N0EAJ133/11/20195059013/11/201950
N0EAJ143/19/20195064013/19/201950
N0EAJ153/21/20195069013/21/201950
N0EAJ163/22/20195074003/21/2019100
N0EAJ173/24/20195079003/21/2019150
N0EAJ183/28/20195084013/28/201950
N0EAJ194/24/2019084003/28/201950
N0EAJ205/8/20195089015/8/201950
N0EAJ216/4/20195094016/4/201950
N0EAJ226/7/20195099006/4/2019100
N0EAJ237/22/201950104017/22/201950
N0EAJ247/29/201950109007/22/2019100

 

This is a sample of the resulting table I'm getting with my current calculations. 

 

 

Any assistance would be great! 

 

Thank you. 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for your input. I was able to figure out. 

Basically what was happening it was calling the customer ID from a different table instead of within the same table. Once I did this minor change, it worked. 

 

(Like you, I tried it with the simple table I sent in my original post, and it worked with the same calculations and measures). 

 

Thanks!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

This is a sample of the data I'm getting when I run the above set of queries. 

Running Score with Reset pic.PNG

hi, @Anonymous 

I have test on my side, it works well on my side.

8.JPG

 

Could you please share your sample pbix file for us have a test? there may be something wrong in other.

 

Best 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

Thanks for your input. I was able to figure out. 

Basically what was happening it was calling the customer ID from a different table instead of within the same table. Once I did this minor change, it worked. 

 

(Like you, I tried it with the simple table I sent in my original post, and it worked with the same calculations and measures). 

 

Thanks!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.