Skip to main content

Notifications

Community site session details

Community site session details

Session Id : rBK+ieLoFfq+IzaEKwSu3g
Power Apps - Building Power Apps
Answered

How to Increment a number with a button

Like (2) ShareShare
ReportReport
Posted on 18 Jun 2021 05:04:38 by 9

Matt_Xiao_0-1623989826120.png

I want to increment the number in a text input by pressing the plus button😅,

I tried Set and UpdateContext in OnSelect but seems not work..

  • joao_guerreiro Profile Picture
    56 on 06 Mar 2023 at 09:48:13
    Re: How to Increment a number with a button

    Better than the not visible button, you should use the DisplayMode property, with the formula:

     

    If(Len(variable) <= 0;DisplayMode.Disabled;If(Int(variable) <= 0;DisplayMode.Disabled;DisplayMode.Edit))
    
    If the input is a text input:
    If(Len(Quantity_Input) <= 0;DisplayMode.Disabled;If(Int(Quantity_Input.Text) <= 0;DisplayMode.Disabled;DisplayMode.Edit))

     

     For the text input formula to work, the input has to have the same name as the one in the formula.


    Hope that this solution has helped you 👍

  • ganeshsanap Profile Picture
    1,551 on 06 Mar 2023 at 05:56:28
    Re: How to Increment a number with a button

    @joao_guerreiro Are you using any collection as datasource for gallery (in items property of gallery)? If yes, you can add one more property in collection which will store the number value.

     

    It will act as a dynamic variable for each item in collection.


    Please click Accept as solution & ‌‌👍 if my answer helped you to solve your issue. This will help others to find the correct solution easily. If the answer was useful in other ways, please consider giving it ‌‌👍

     

    For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs

  • joao_guerreiro Profile Picture
    56 on 17 Feb 2023 at 14:07:45
    Re: How to Increment a number with a button

    Hello @ganeshsanap thank you for your solution 😄

    This worked in my gallery, the only problem I'm facing is that the variable is shared through everyline in the gallery, how do I assign a new variable with the same properties to every row that is added?

  • rosscortb Profile Picture
    186 on 28 Oct 2022 at 09:04:23
    Re: How to Increment a number with a button

    @KennyJ 

    Thanks for your response.

    I worked out how to hide button so thanks.

    For the input field, as you can see if have the first box set as var1 so then next one needs to be var2 from your reply but you can't see how you edit that field as everything you do in the first container is pulled through to the rest when previewing? I'm obviously missing something.

     

    Thanks

    Ross

    Screenshot 2022-10-28 100028.png

  • KennyJ Profile Picture
    168 on 27 Oct 2022 at 21:06:58
    Re: How to Increment a number with a button

    Hi Ross,


    1) You can use the visible, or display mode property of the button based upon the variables value.  I.e, when 0 you could hide the button.  

    2) For each input field you need to set the Text property to the name of your variable. You will need a separate variable for each input text.

     

    Thanks

    Kenny

     

  • rosscortb Profile Picture
    186 on 27 Oct 2022 at 10:47:46
    Re: How to Increment a number with a button

    @ganeshsanap 

     

    Sorry, jumping on this post. I have created something similar.

    Had a couple of questions.

    1.  How do I prevent the - button going below zero?

    2. Also, how do I link input field to each product as when testing in preview it is increasing all values for each product.

    Do I need to add ThisItem.Product in var1? just thinking out loud

    Thanks

    Ross

     

    Screenshot 2022-10-27 114317.png

  • Verified answer
    ganeshsanap Profile Picture
    1,551 on 20 Jun 2021 at 07:24:15
    Re: How to Increment a number with a button

    @Matt_Xiao Follow below steps:

     

    1. Use below formula on onStart of App or onVisible of screen control: 

     

    Set( var1, 0 )

     

    2. Set Default property of TextInput1 control to var1.

    3. Set onSelect property of button control to: 

     

    Set( var1, var1 + 1)

     


    Please click Accept as solution & 👍 if my answer helped you to solve your issue. This will help others to find the correct solution easily. If the answer was useful in other ways, please consider giving it ‌‌👍

  • KennyJ Profile Picture
    168 on 20 Jun 2021 at 07:13:22
    Re: How to Increment a number with a button

    You need to delete that first line and then in the Default of the text box just set it to var1

  • Matt_Xiao Profile Picture
    9 on 20 Jun 2021 at 03:10:35
    Re: How to Increment a number with a button

    Hi Kenny, 

    Thanks for your reply. Please see the screenshot below

    Matt_Xiao_0-1624158594768.png

     

  • KennyJ Profile Picture
    168 on 18 Jun 2021 at 05:50:30
    Re: How to Increment a number with a button

    you certainly have the right method so you must have an error somewhere.  

    for your input box, the default should be something like varNumber.  Then on the onselect of the button you would have UpdateContext({varNumber: varNumber+1})

     

    if this doesn’t work then maybe share what you have put. 

    thanks

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
MS.Ragavendar Profile Picture

MS.Ragavendar 32

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 19 Super User 2025 Season 1

#3
WarrenBelz Profile Picture

WarrenBelz 18 Most Valuable Professional

Overall leaderboard