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 / Update variable onChange
Power Apps
Answered

Update variable onChange

(0) ShareShare
ReportReport
Posted on by 817

Hi All, i have this Expense report application where people track their expenses while on a business trip.

The logic of the trip expense is the following:

 

  • First, you have an SPO list that contains information about your trip, start date, end date, etc.
  • Then using a preparing table in PA users start reporting their expenses. The app calculates immediately the total amount of all expenses based on each line in the repeating table

Radoslavov_0-1667293455840.png

  • Once the user submits the form, for each record in the repeating table, an expense record is created in the SPO list.

Radoslavov_1-1667295464840.png

  • The user has the option from the app to do any changes to the expense trip if needed, for example, if the price value is wrong.
  • The problem I'm facing is that I'm wondering how to make when the user corrects the price of an expense item this to update the Summary tab which information is stored on the Trip record.

Radoslavov_2-1667295620380.png

So far i come up with the following idea:

 

Two variables.

varRecord - which stores information about the selected trip

Radoslavov_3-1667295707983.png

varExpenseRecord that stored information about selected expense record 

Radoslavov_4-1667295757252.pngRadoslavov_5-1667295786273.png

I'm guessing that I should have a formula onChange of the inpExpenseValue field, to update the varExpenseRecord value column with the new value. 

But I also need to somehow calculate in the varRecord the new total amount for Refundcash and TotalForReimbursement

 

Something like this:

 

Current values:

varRecordRefundcash 244 TotalForReimbursement 244

varExpenseRecord  - Value 160

 

New values:

varExpenseRecord - Value 100

varRecord - Refundcash 144 TotalForReimbursement 144

 

And from here I will have an Update button that will just patch the new variables data back to the respective SPO list items for trips and expenses which I already know how to do.

 

Any suggestion on how to solve the problem with the calculations?

 

Thank you in advance,

 

Kiril

Categories:
I have the same question (0)
  • Verified answer
    Feline Profile Picture
    92 on at

    You could make the total in your summary dynamic by using the Sum() function, for example on all the items in your gallery with your expenses (Shell, McDonalds ...) and then summing Value.

    Sum(Gallery.AllItems, Value)

    This would make sure that the total changes from the moment you update a value by submitting your form.

     

    You could on the same update button also patch the total to the expense info list by patching the specific record, for example where Title = "Trip 1" in the above case.

    Alternatively, you could add a resubmit expense report button to patch only once, when all the changes are made to the values.

  • Radoslavov Profile Picture
    817 on at

    Thank you @Feline indeed that solves the problem and now after a change is made for a record it's patched to the expense and from there visible on the form for the user with updated values for total reimbursement, It was simpler than I thought, thanks to your  easy explanation 🙂 

     

    Thank you for the assistance once again and stay safe!

     

    Regards,

    Kiril

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 834

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard