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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Create a new column that calculates a running total for each unique ID in another column

I am having an issue creating a new column that calculates a running total for each unique ID listed. For example:

 

ID          Bill          Date          Running Total (this is what I need)

1           105         1/1/19       105

2           103         1/1/19       103

1           110         2/1/19       215

2           98           2/1/19       201

3           132         2/1/19       132

 

Now, I have sucessfully created a measure that calculates the running total, but I am having difficulty figuring out the right filter, or group.... to use. Here is what I have so far.

 

Total = CALCULATE(
            SUM('Table1'[Bill]), 
            FILTER('Table1', 'Table1'[Date] <= EARLIER('Table1'[Date]))
        )

 

This calculation works and creates a valid result. However, it is the sum for all the Id's listed.

 

My main issue, is my Id field is not distinct, because each Id has a monthly entry, it appears numerous times. My goal is to create a column that shows the sum of the current bill and all previous bills for each Id.

 

Any assistance would be much appreciated.

1 ACCEPTED SOLUTION

Hi @Anonymous 
Or this:

Running Total 2 = 
Var _curDate = myTable[Date]
Var _curID = myTable[ID]
var _calc = CALCULATE(SUM(myTable[Bill]),myTable[Date]<=_curDate,myTable[ID]=_curID, All(mytable))
return _calc

runntot1.PNG

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,
runntot.PNG

 

Try this:

Running Total =
VAR _curDate = myTable[Date]
VAR _calc =
    CALCULATE (
        SUM ( myTable[Bill] ),
        FILTER ( ALLEXCEPT ( myTable, myTable[ID] ), MAX ( myTable[Date] ) <= _curDate )
    )
RETURN
    IF ( ISBLANK ( _calc ), myTable[Bill], _calc )

Using variables in your DAX rather than Earlier is recommended now. 
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @Anonymous 
Or this:

Running Total 2 = 
Var _curDate = myTable[Date]
Var _curID = myTable[ID]
var _calc = CALCULATE(SUM(myTable[Bill]),myTable[Date]<=_curDate,myTable[ID]=_curID, All(mytable))
return _calc

runntot1.PNG

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thanks for the assistance! I ended up using the second solution you posted. It is correctly calculating the running total bill for each account ID in my data as I intended. Awesome job!

@Anonymous ,
You are welcome!

Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.