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 / + and - Button to add ...
Power Apps
Unanswered

+ and - Button to add and subtract from a Quantity.

(0) ShareShare
ReportReport
Posted on by

I am using an spreadsheet from OneDrive as a simple inventory app. I would like to have a + and - Button with the current quantity shown on the first page of the app. I was able to setup the layout I wanted but I cannot get the buttons to work the way I want. How could I make the + add 1 to the quantity and the - button subtract from the quantity?

Categories:
I have the same question (0)
  • Brian Dang Profile Picture
    3,976 on at

    It depends. 

    • are the +/- buttons part of a gallery of items whose quantity changes or is it a single variable?
    • do you need to save the variable to the datasource right away?

     

    If the +/- buttons are changing a just one variable for a Screen, then use UpdateContext:

     

    Button1: UpdateContext({quantity: quantity+1})
    Button2: UpdateContext({quantity: quantity-1})

     

     

     

    Note: Or if you want the variable to be global, then use a Collection instead of a UpdateContext.

     

    If the +/- buttons are repeated as part of a gallery or collection, configure the +/- buttons to change the values of the datasource itself.

    Button1: Patch(datasource,ThisItem,{quantity: ThisItem.quantity+1})
    Button2: Patch(datasource,ThisItem,{quantity: ThisItem.quantity-1})

     

    If you need to save the quantity immediately upon making any changes, then Patch() the changes right away.

     

    If you can wait to apply all changes at once, then Collect the changes as you add or subtract and Patch the changes afterwards.

     

    ForAll(changes,
    	Patch(datasource,[identify each row],
    		{quantity: quantity
    		}
    	)
    )

    Note: you may need to use disambiguation or RenameColumns since the column "quantity" has the same name.

     

     

  • Jellybean Profile Picture
    4 on at

    I am trying to add + and - buttons to my app to make it easier to update stock quantities.  I know absolutely nothing about code and have tried the solutions on this page with no success.  (I added in the right names for my data but the formula is highlighting an error at +1

     

    Patch(datasource,'Stock List',{quantity: Quantity_x0020_in_x000a_Stock.quantity+1})

     

     

    Can someone explain for the technically challenged please?  Am I right in thinking Patch means it will send the info back to the data source?

     

  • KatW Profile Picture
    15 on at

    Were you ever able to get this to work?

  • Jellybean Profile Picture
    4 on at

    No - gave up.  We're using a prehistoric count and update spreadsheet method instead.  

     

    Make apps without code?- not really. 

  • imranfc Profile Picture
    10 on at

    please solve this issue my value not change use this formula ?

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

    @imranfc ,

    I suggest you post a new thread on this with details of what you require as you will have more chance of a response.

  • imranfc Profile Picture
    10 on at

    Hello sir,
    how to reset inputtext default value.

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard