Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Addition and Subtract balance in Gallery

(0) ShareShare
ReportReport
Posted on by 438

Hello, I'm trying to find a way to perform addition and subtraction using functions.

 

Before, my name was 'Dylan Davis,' and I had a balance of '0' in the list.

Screenshot 2023-11-04 132708.png

When staff or teachers fill out the form and submit it, students can view the transaction history to see where teachers or staff have received deposits or withdrawn Dragon Tickets.

Screenshot 2023-11-04 132132.png

 

After submitted, the deposit or withdrawn should be updated to numbers for students and displayed as number on the screen, it is connected to the SharePoint list 'DHS Student Users'. Addition is indicated by a plus sign (+) for DESPOSIT, while subtraction is represented by a minus sign (-) for WITHDRAWN. Where's $45??

Screenshot 2023-11-04 132708.png

 

Last thing, regarding my transaction history: How can I look up if the User().Full name matches and display a list, which may contain more than one entry?

Screenshot 2023-11-04 134744.png

  • Verified answer
    cdwhite Profile Picture
    1,067 Most Valuable Professional on at
    Re: Addition and Subtract balance in Gallery

    Hi @dylandavis09 ,

    Ok, this is what I've done at my end, works ok at the moment but may need something better.

    I've added a text input box to add values, called txtValue. I've also got a dropdown box called dpdChoice that has Deposit & Withdrawn as the two options. I've also added a user email & ID column for unique identifiers as more than one person could have the same name.


    I have a button that, when clicked, will:
    a) add a new transaction to the Transactions list

    b) update the D-Tickets value for the relevant user

    So adding the transaction:

    // Determine whether value will be a positive or negative amount
    With(
     {
     tvValue: If(
     dpdChoice.Selected.Value = "Deposit",
     Value(txtValue.Text),
     Value(txtValue.Text) * -1
     )
     },
    // Create new entry in Transactions list 
     Patch(
     'Transaction History',
     Defaults('Transaction History'),
     {
     Title: "Dylan Davis",
     Email: "dylan.davis@email.com",
     UserID: 1,
     Deposit: Value(tvValue),
     'Deposit Type': dpdChoice.Selected.Value
     }
     )
    );


    Then, updating the D-Tickets value for the relevant user. I'm using the List ID of the person for a one-to-one match:

    // Sum all of users transactions
    With(
     {
     tvSum: Sum(
     Filter(
     'Transaction History',
     UserID = 1
     ),
     Deposit
     )
     },
    // Update users D-Tickets total 
     Patch(
     'DHS Student Users',
     {ID: 1},
     {'D-Tickets': tvSum}
     )
    )

    I've tested at my end and works ok, though may need a better solution that avoids delegation:

    cdwhite_0-1699221556580.png


    ------------------------------------------------------------------------------------------------------------------------------
    If I've answered your question, please mark your post as Solved. You can accept more than one post as a solution.

    If my response was a good one, please give it a Thumbs Up!

    Visit my blog: https://platformsofpower.net

  • dylandavis09 Profile Picture
    438 on at
    Re: Addition and Subtract balance in Gallery

    @cdwhite, thank you for understanding what I want to achieve. Let me explain. You are correct: when a new line is added to the PBiS Transaction History, we need to sum up all transactions for one student and then send the updated totals to the DHS Student Users. For example, if a teacher makes a $45 deposit and later another $100 deposit, there should be an overall total that needs to be updated in the list based on the matching full name.

     

    How it makes if deposit (sum), and withdrawn (subtract).

     

    PBiS Transaction History:

    Dylan Davis              $45            Deposit

    Dylan Davis              $100          Deposit

     

    Need to update the DHS Student Users:

    Dylan Davis              $145

  • cdwhite Profile Picture
    1,067 Most Valuable Professional on at
    Re: Addition and Subtract balance in Gallery

    Hi @dylandavis09 ,

    If I understand correctly, when the line is added to the PBiS Transaction History list, it needs to update the entry for the relevant student in the DHS Students Users list? If so, would that mean you'll need to sum up ALL transactions for one student? For example, Dylan could have multiple transactions at $45, so would there need to be an overall total that needs updating?

     

    In terms of your query around User().FullName - you're correct, this won't be unique as multiple people could have the same name. In Active Directory & Exchange, this is bypassed by the users email address, as this will ALWAYS be unique to the individual user. You can access this with User().Email, though I'd always recommend the Office 365 Users approach personally.
    ------------------------------------------------------------------------------------------------------------------------------
    If I've answered your question, please mark your post as Solved. You can accept more than one post as a solution.

    If my response was a good one, please give it a Thumbs Up!

    Visit my blog: https://platformsofpower.net

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard