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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Modifying a number on ...
Power Apps
Answered

Modifying a number on a table.

(0) ShareShare
ReportReport
Posted on by 32

Hi everyone,

I am building a canvas app in which I save data from users' inputs. The contract ID is the key of all, as I use it as a kind of database ID. So, when I entered a new order, first thing the app does is to look for this ID. If it doesn't exist, data is just saved in a new row.This function works perfectly. However, if it exists, I want a column of the data source in which I save quantities, 'Total_Quantity' to be modified by adding up the new number to the previous one. The problem is that I can't find a better solution than this one but it's not only not modifying but also adds a new row. AS you can see I extract the value of the column in the specified record and then try to add it up with the current value. But nothing works.

 

 

 

 

//Block in which, depending what data is saved if there is a previous order with the same Contract.
If(
 //Condition for modifying an existing record
 LookUp(
 Registry,
 Contract = contract.Text,
 Contract
 ) = contract.Text,
 Patch(
 Registry,
 LookUp(
 Registry,
 Contract = contract.Text
 ),
 {Total_Quantity:(LookUp(Registry,Contract = contract.Text,Total_Quantity))+quantity.Text}
 ),
 //Condition for creating a new record
 Patch(
 Registry,
 Defaults(Registry),
 {Contract: contract.Text},
 {Date: Text(Date.SelectedDate)},
 {Customer: customer.Text},
 {Country: Ddwn_country.SelectedText.Value},
 {Requested_Date: Text(RequestedDate.SelectedDate)},
 {Condition: Ddwn_condition.SelectedText.Value},
 {Total_Quantity: quantity.Text}
 )
)

 

 

 

 

 

Thanks beforehand

 

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

    Hi,
    [

    Try this code 

    //for modifying an existing record
    If(Not(IsBlank(LookUp(Registry, Contract = contract.Text))),
     Patch(
     Registry,
     LookUp(Registry, Contract = contract.Text),
     {
     Total_Quantity: LookUp(Registry, Contract = contract.Text, Total_Quantity) + Value(quantity.Text)
     }),
     // Create a new record
     Patch(Registry,Defaults(Registry),
     {
     Contract: contract.Text,
     Date: DateValue(Text(Date.SelectedDate)),
     Customer: customer.Text,
     Country: Ddwn_country.Selected.Value,
     Requested_Date: DateValue(Text(RequestedDate.SelectedDate)),
     Condition: Ddwn_condition.Selected.Value,
     Total_Quantity: Value(quantity.Text)
     }))

    ]

     

    Please give a thumbs up if this information is helpful.

     

    Best regards,
    Ali Sheraz

  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at

    HI @RC6 ,

    You have not stated your data source here (hopefully not Excel as things often do not work there), but try this

    With(
     {
     _Exist:
     LookUp(
     Registry,
     Contract = contract.Text
     )
     },
     If(
     !IsBlank(_Exist.Contract),
     Patch(
     Registry,
     LookUp(
     Registry,
     Contract = contract.Text
     ),
     {Total_Quantity: _Exist.Total_Quantity + Value(quantity.Text}}
     },
     Patch(
     Registry,
     Defaults(Registry),
     {
     Contract: contract.Text,
     Date: Text(Date.SelectedDate),
     Customer: customer.Text,
     Country: Ddwn_country.Selected.Value,
     Requested_Date: Text(RequestedDate.SelectedDate),
     Condition: Ddwn_condition.Selected.Value,
     Total_Quantity: Value(quantity.Text)
     }
     )
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • RC6 Profile Picture
    32 on at

    Thanks Ali, it worked perfectly after some attempts. I realized that the problem with adding a new row to the table was due to having the table open at the same time. So in the end it worked. Thanks so much.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard