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

Community site session details

Session Id : TdSx215ww+2parJOPgRPt5
Power Apps - Building Power Apps
Answered

Create a Button to increase a number field value by one

Like (0) ShareShare
ReportReport
Posted on 9 Feb 2021 16:19:41 by 3,502

I have the following power app form:-

 

redgreen.png

 

now i want to increase the ScoreGreenPoint by 1 when the user clicks on the "+ Green" button? is this possible?

 

Thanks

Categories:
  • johnjohn123 Profile Picture
    3,502 on 10 Feb 2021 at 23:19:32
    Re: Create a Button to increase a number field value by one

    @RandyHayesthat also makes sense to me now.. thanks

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 10 Feb 2021 at 23:17:25
    Re: Create a Button to increase a number field value by one

    @johnjohn123 

    Actually you will want to Set(varGreenScore, Blank())

     

    If you set it to 0 then this formula:

       Coalesce(varGreenScore, Parent.Default, 0)

    Will always show 0, because varGreenScore is NOT blank.

    Coalesce returns the FIRST non-blank value in the list of parameters.  If you set that variable to 0, then varGreenScore will not be blank and thus the rest will never evaluate properly.

    If you set it to Blank, then it will work properly.

  • johnjohn123 Profile Picture
    3,502 on 10 Feb 2021 at 23:07:18
    Re: Create a Button to increase a number field value by one

    @RandyHayesok makes sense now... so i need to define

     

       Set(varGreenScore, 0)

     

    on the onsuccess of the form, so i will be fine? is this correct? or you are against using variables at all?

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 10 Feb 2021 at 23:02:58
    Re: Create a Button to increase a number field value by one

    @johnjohn123 

    In the context of SharePoint Integration.  When you submit the form and it closes (RequestHide()) it does not actually close the Form/app, it simply hides it.  If you close the browser and then go back to the list, the variables will be gone.  That is because the closing of the browser caused the "hidden" app to close.

    When you click to "new" a record, it is just making the hidden app visible - so it will not have closed and the variables would still have their values.

     

    It is best not to rely on this concept for maintaining variable state as, as mentioned, once the browser is closed or refreshed, the form/app will go away and no longer have its values.

  • johnjohn123 Profile Picture
    3,502 on 10 Feb 2021 at 22:33:49
    Re: Create a Button to increase a number field value by one

    @RandyHayes  can you explain this in more details? what do you mean by close the app? as i test this where i submit the form which will close the app >> but when i click on New button a new form will open and the form will use the variable from the previous form submission ...so the variable will not lose its value when we close the app...

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 10 Feb 2021 at 22:25:01
    Re: Create a Button to increase a number field value by one

    @johnjohn123 

    Variables do not lose their values unless you close the app.

    In your OnSuccess of your Form, you should set the variable to Blank()

    I assume you are doing a SubmitForm somewhere in order to save your form data?

  • johnjohn123 Profile Picture
    3,502 on 10 Feb 2021 at 18:34:06
    Re: Create a Button to increase a number field value by one

    @RandyHayesyou are correct .. so where i need to set Blank() ? also why this happen at the first stage? should not the variable life time ends when we close the form?

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 10 Feb 2021 at 18:24:43
    Re: Create a Button to increase a number field value by one

    @johnjohn123 

    You will want to use the Blank()

    If not, then if you open one record and let's say increment to 10, then open another record, it will show 10 and not the actual record value.

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on 10 Feb 2021 at 18:22:26
    Re: Create a Button to increase a number field value by one

    You are using the variable.  You have used this formula in your Default property:

     

    Coalesce(varGreenCount, Parent.Default, 0)

     

    Coalesce is the function that evaluates varGreenCount and Parent.Default then determines which value to display.

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on 10 Feb 2021 at 18:19:31
    Re: Create a Button to increase a number field value by one

    On using the Coalesce, to make sure I understand, it works on the presumption that only one will have a value at any given time other than blank, correct?

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete