web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Stop running total fro...
Power Apps
Answered

Stop running total from changing.

(0) ShareShare
ReportReport
Posted on by 6

Hi,
Is there a way to stop my running total for one record from changing when another record is updated?

 

In my form, I have a running total data card where I select the Add button, which sets the OnSelect property to Set( RunningTotal, RunningTotal + TextInput1 )

 

This works as it should, but when I save and go back to my gallery and update another record, the first record’s running total changes on its own.

 

Thanks in advance!

Categories:
  • Verified answer
    JatinSaini Profile Picture
    428 on at


    It seems like the issue you're facing in Power Apps is due to the use of a global variable (RunningTotal) to calculate the running total. When you update another record, the global variable is still being used, and that's why the running total for the first record changes.

    To fix this, you need to ensure that each record has its own independent running total. One way to achieve this is by using a collection to store the running totals for each record. Collections in Power Apps are in-memory tables that can hold data during the session.

    Here's how you can modify your approach to handle the running total for each record:

    Create a collection to store the running totals:
    In the OnStart property of your app, add the following code to create the collection:

     

    ClearCollect(RunningTotalsCollection, { RecordID: "", RunningTotal: 0 })


    Modify the Add button's OnSelect property:
    Update the OnSelect property of your Add button to add the current record's running total to the collection.

     

    Collect(RunningTotalsCollection, { RecordID: ThisItem.ID, RunningTotal: RunningTotal + TextInput1 })


    Display the running total in your form:
    Instead of using the global variable directly, use the collection to display the running total for the current record in your form.

     

    LookUp(RunningTotalsCollection, RecordID = ThisItem.ID, RunningTotal)


    By following these steps, each record will have its own running total value stored in the collection. Updating one record won't affect the running total for another record.

     

    Remember to replace TextInput1 with the appropriate control or variable name that holds the value to be added to the running total. Also, make sure to adjust the RecordID field in the collection based on your data source's unique identifier for each record. If your data source doesn't have a unique identifier for each record, consider using a combination of fields that can uniquely identify each record.

  • JamesW123 Profile Picture
    6 on at

    Thanks for your quick, detailed response!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 190 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard