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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add/Subtract +1/-1, th...
Power Apps
Answered

Add/Subtract +1/-1, then refresh label

(0) ShareShare
ReportReport
Posted on by 278

Z.PNG

 

The number in the middle is a label with it's Text:  'House DropDown_7'.Selected.Scooter

 

This is the plus button's Onselect

 

Patch('Database Output',

'House DropDown_7'.Selected,

{Scooter: (Value(Label2_981.Text)+1)});

Refresh('Database Output')

 

If I set the label Text to be "0", then the Google Sheet value turns to '1

 

If I start with Scooter being a 1,  then it turns it into a '2

 

 

 

And the label doesn't refresh at all, it just stays the same.  Why am I getting a  '   in front of my numbers & why is this not refreshing?

 

Categories:
  • Verified answer
    GarethPrisk Profile Picture
    2,828 on at

    A couple of observations/recommendation:

    • Instead of patching every time the value changes, I recommend that you have a single Patch function that is available on 'Save' button or equivalent - this will allow you to capture multiple changes and cut down on performance-heavy calls until necessary
    • Use context, or global, variables for these types of rapid-fire updates
      • It allows you to interact with the data in a more concise way
      • It prevents the app from having to refresh/read data for every click
      • Much smoother process overall
      • You'll be be able to see what the new value will be/was set to when troubleshooting in Studio

     

    For your example, I would capture the row's 'Scooter' value when it row is selected initially.

    UpdateContext({locValueScooter: Value('House DropDown_7'.Selected.Scooter)});

    Now we have a way to track the value that is on the row, relative to what the user is doing in the app itself.

    The Label showing the value would simply have a Text property of: locValueScooter

    The increment/decrement functions would be.

    UpdateContext({locValueScooter: locValueScooter + 1 });
    
    UpdateContext({locValueScooter: locValueScooter - 1 });

    Then your Patch will use that variable's value, as well. (As it's written, your patch may need to have a more concise BaseRecord parameter, to ensure you're updating the correct row)

    Patch(
    'Database Output',
    'House DropDown_7'.Selected,
    {Scooter: locValueScooter }
    );

    Also, this approach has some additional advantages. Since you've basically got a snapshot of the current and desired 'Scooter' values, you can easily produce a True/False to see if it has changed. You could put this on your 'Save' button to show/hide, or enable/disable it until they user has made a change. Now if you can imagine repeating this for multiple inputs, then it becomes much easier to track each individual change.

    Value('House DropDown_7'.Selected.Scooter) <> locValueScooter

    Hope this helps!

  • Verified answer
    mdevaney Profile Picture
    29,993 Moderator on at

    @Humanity

    A Power Apps Canvas Component was already built to do this.  I'll provide a link to it below.  You can either use the component or study it to build your own.

     

    Link to Numeric Up/Down Component

    https://powerusers.microsoft.com/t5/Canvas-Apps-Components-Samples/Numeric-Up-Down-Control/td-p/325535

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 383 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 356

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard