cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sahara22
Post Patron
Post Patron

How to show the count of button clicks

Hello, 

 

looking for something really simple

bit can’t figure it out. 

in a label , I would like to show the amount of clicks someone presses a button.  At work we have to count certain items but they are everywhere so it’s just easy to click a button as we see the item and automatically shows the count . 

for example 

the label would show “20” if I pressed a button 20 times. 

thank you!!

1 ACCEPTED SOLUTION

Accepted Solutions
PowerAddict
Super User
Super User

Hi @Sahara22

 

You can simply do something like this in the OnSelect of the button:

Set(gblCount, gblCount+1)

Or

UpdateContext({locCount: locCount+1})

Or

Collect(colCount, CountRows(colCount)+1)

And then you can set the Text property of the label to:

gblCount or locCount or CountRows(colCount)

 

Let me know if this helps.

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Microsoft Business Applications MVP

Microsoft Certified Trainer MCT

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

View solution in original post

12 REPLIES 12
PowerAddict
Super User
Super User

Hi @Sahara22

 

You can simply do something like this in the OnSelect of the button:

Set(gblCount, gblCount+1)

Or

UpdateContext({locCount: locCount+1})

Or

Collect(colCount, CountRows(colCount)+1)

And then you can set the Text property of the label to:

gblCount or locCount or CountRows(colCount)

 

Let me know if this helps.

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Microsoft Business Applications MVP

Microsoft Certified Trainer MCT

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

Sahara22
Post Patron
Post Patron

Thank you @PowerAddict !! Exactly as I wanted! Your awesome!!

PowerAddict
Super User
Super User

Glad I could help! Good luck with the rest of the app! Feel free to reach out in case of any questions!

 

Thanks!

Hardit Bhatia

Microsoft Business Applications MVP

Microsoft Certified Trainer MCT

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

Sahara22
Post Patron
Post Patron

Thank you @PowerAddict ,

 

i actually have one more sorry. I’m trying to now rest set the value of the table so it can start at zero again but the “Reset(BT.text)” won’t work on another button (the reset button on) . “BT” is the label name. 

thank you!! 🙂 

PowerAddict
Super User
Super User

Wherever you want to reset the count, depending on the approach you picked you can do one of the following:

Set(gblCount, 0)

Or

UpdateContext({locCount: 0})

Or

Clear(colCount)

Let me know if this helps.

 

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Microsoft Business Applications MVP

Microsoft Certified Trainer MCT

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

Sahara22
Post Patron
Post Patron

Wow thanks again @PowerAddict . Ok last question I promise.  Now I want to make another button that sends the count to an email, for example I have this: 

 

Office365Outlook.SendEmail("email@hotmail.com", "Stock Count", "Here are the Counts");Navigate('Home Page')

how can I add the value number to the above? 

Thanks again so much!! 

 

PowerAddict
Super User
Super User

Try this: 

Office365Outlook.SendEmail("email@hotmail.com", "Stock Count", "Here are the Counts: " & gblCount);Navigate('Home Page')

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Microsoft Business Applications MVP

Microsoft Certified Trainer MCT

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

Sahara22
Post Patron
Post Patron

Honestly, your so awesome @PowerAddict . That’s it for me! Thanks so much again!! 😁😁

Sahara22
Post Patron
Post Patron

Hahha I’m so sorry, really this is the last thing. Is there a way to send it to the user who is using the app? So I have it sending it to someone specific but if I want the user to send it to himself , how do I do that? Thank you!!!!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,887)