Skip to main content
Community site session details

Community site session details

Session Id : WEW5wyvbAwZ9OkzXLgnC/v
Power Apps - Building Power Apps
Answered

PATCH Simple Math Function (Lookup)

Like (0) ShareShare
ReportReport
Posted on 30 Dec 2023 14:17:04 by 309

I have a PATCH command which should be applying a simple math function, to minus 5 from an existing Value - but it is not working. The intent is to LookUp the user's record in a SharePoint List called PROFILES, then minus 5 from the existing Value in Credits for that Record:

Patch(LookUp(PROFILES,User().Email = email),{Credits:LookUp(PROFILES,User().Email = email).Credits - 5});

 

This is simply not completing the subtraction and I cannot fathom why - any pointers would be greatly appreciated - thanks!

Categories:
  • AdamGill1965 Profile Picture
    309 on 30 Dec 2023 at 14:34:37
    Re: PATCH Simple Math Function (Lookup)

    Thank you - sometimes you get too deep in to see rudimentary issues - I see now I forgot to define the Data Source in my PATCH command, as you have indicated. All working now - thanks!

  • Verified answer
    ANB Profile Picture
    7,128 Super User 2025 Season 2 on 30 Dec 2023 at 14:29:09
    Re: PATCH Simple Math Function (Lookup)

    Hi @AdamGill1965, The syntax of patch is as follow:

    Patch( DataSource, BaseRecord, ChangeRecord1 [, ChangeRecord2, … ])

    • DataSource – Required. The data source that contains the record that you want to modify or will contain the record that you want to create.
    • BaseRecord – Required. The record to modify or create. If the record came from a data source, the record is found and modified. If the result of Defaults is used, a record is created.
    • ChangeRecord(s) – Required. One or more records that contain properties to modify in the BaseRecord. Change records are processed in order from the beginning of the argument list to the end, with later property values overriding earlier ones.

    In your code I dont see the Data source. Try this:

     

    Patch(
     PROFILES, 
     LookUp(PROFILES,User().Email = email),
     {
     Credits: LookUp(PROFILES,User().Email = email).Credits - 5
     }
    );

     

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.👍

    Thanks,
    ANB


     

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete