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 / Adding to Existing Qua...
Power Apps
Answered

Adding to Existing Quantity

(0) ShareShare
ReportReport
Posted on by 53

So I am building an Inventory management app and currently when you want to add an item to the app you fill out a form and I use

 

SubmitForm(EditForm)

 

 to update the list. 

 

This form includes the name, part number, location and quantity. What I want is that when the form is filled out, the user clicks submit and IF the part number he has entered already exists in the excel file, the quantity he entered will just be added to the existing quantity in the excel file.

 

I'm sure this isn't as hard as I think it is but I have tried using an If statement as shown below but it hasnt worked. 

 

If(LookUp(Table1 , 'PartNumber' = PNCard.Text),{Qty:Value( Qty.Text +QtyInputCard.Text))}, SubmitForm(EditForm3); 

 

I am aware this syntax is way off but I'm hoping you can get an Idea as to what I am thinking

 

Any help will be greatly appreciated, Thanks 🙂 

 

Categories:
I have the same question (0)
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

     Hi @KarlAddi 

     

    • Use Lookup to get the item for the same part number and same Quantity
    • Get the PartNumber from the Lookup.
    • If Partnumber exist it means part number exists
    • Adding ! 
    • The form will submit if no part number and qty

     

    If(!IsBlank(LookUp(Table1 , 'PartNumber' = PNCard.Text && Qty = QtyInputCard.Text).PartNumber), SubmitForm(EditForm3)); 

     

     

    My Sample for Reference

    If(
     !IsBlank(
     LookUp(
     IssueTracker,
     Title = Title1.Text && Qty = Value(Qty.Text)
     ).Title
     ),
     SubmitForm(EditForm1)
    );

     

  • KarlAddi Profile Picture
    53 on at

    Hi thanks for your reply 🙂 

     

    That's not exactly what Im looking for. So I want to check by just the part number and if that part number exists, what ever the user has input for the quantity on the form, I want to add that quantity to the current quantity we already have on the excel file. 

     

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @KarlAddi 

     

    • Get Existing Item
    • Get the Qty
    • If item found , add to existing qty with current qty

     

    ClearCollect(
     GetExisting,
     LookUp(
     IssueTracker,
     Title = Title1.Text
     )
    );
    Set(
     GetQty,
     If(
     IsBlank(GetExisting) || IsEmpty(GetExisting),
     0,
     Value(First(GetExisting).Qty)
     )
    );
    Patch(
     IssueTracker,
     If(
     !IsBlank(GetExisting.Title),
     LookUp(
     IssueTracker,
     Title = Title1.Text
     )
     ),
     {Qty: Value(QtyDataCardValue.Text) + GetQty}
    );

     

     

     

  • Verified answer
    StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @KarlAddi 

     

    • Updated with your table and column names
    • This patch command creates a new record if not found

     

     

     

    ClearCollect(
     GetExisting,
     LookUp(
     Table1,
     Title = Title1.Text
     )
    );
    Set(
     GetQty,
     If(
     IsBlank(GetExisting) || IsEmpty(GetExisting),
     0,
     Value(First(GetExisting).Qty)
     )
    );
    Patch(
     Table1,
     If(
     IsBlank(GetExisting.Title),
     Defaults(Table1),
     LookUp(
     Table1,
     Title = PNCard.Text
     )
     ),
     {
     'PartNumber': PNCard.Text,
     Qty: Value(QtyInputValue.Text) + GetQty
     }
    );

     

     

     Note: We need to add other columns to this patch command

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @KarlAddi 

    You will want to take care of this in the OnSuccess action of your form rather than before you submit form.  This adds a level of error management in case there is a failure in the submit.

    In your OnSuccess, set the Formula to the following:

     

    With({_item: LookUp(Table1, 'Part Number'=Self.LastSubmit.'Part Number')},
     Patch(
     Table1,
     Coalesce(_item, Defaults(Table1)),
     {'Part Number': Self.LastSubmit.'Part Number',
     Qty: Coalesce(_item.Qty, 0) + Self.LastSubmit.Qty
     }
     )
    ) 

     

    This will increment the Qty of the existing part, or add the part and set the Qty if it does not exist.

    Note: The above formula assumes that the names of the columns in your EditForm are the same as in your Table1 records (i.e. 'Part Number' and Qty), if they are not, adjust accordingly.

     

    Also, importantly, this references the LastSubmit property of the EditForm which should be used rather than referencing the controls that are in the form as their state may change.  LastSubmit is a snapshot of the record that was last submitted.

     

    I hope this is helpful for you.

  • pablik01 Profile Picture
    on at

    How to change quanity in collection?

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 765 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 272

Last 30 days Overall leaderboard