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 : JmnYNgFsS5LNu0QuLidMun
Power Apps - Building Power Apps
Answered

Count Button Clicks

Like (0) ShareShare
ReportReport
Posted on 17 Mar 2025 16:11:34 by 786
Hi,

I have a requests for something that I have not come across how to do before.
 
The challenge is I have an app that has a button that currently copies something on Select, however to add to its functionality I want to build something that counts the amount of times this button is selected during a working day (the app is accessed by multiple users)
 
Is this doable if so what is the best approach to doing so?
 
 
  • Kmayes Profile Picture
    786 on 18 Mar 2025 at 17:01:31
    Count Button Clicks
    @GabGadou 

    Unfortunately the button isn't currently creating any records its current purpose is to create copy text, but off the back of the button I wanted to understand how many time that button is being clicked by the multiple users. Otherwise id have lifted from a database (had there been one) how many clicks occurred.
  • MS.Ragavendar Profile Picture
    2,779 Super User 2025 Season 2 on 18 Mar 2025 at 12:19:52
    Count Button Clicks
    Hi,
     
    If you feels the below approach will create multiple entries for one user, try this .
     
    The list schema remains the same, we changing only in the patch, OnSelect of Button.
     
    ClearCollect(
        colExistingRecord, 
        Filter(ButtonClicks, UserEmail = User().Email, ClickDate = Today())
    );
    
    If(
        CountRows(colExistingRecord) > 0,
        // If a record exists, update it
        Patch(
            ButtonClicks,
            First(colExistingRecord), 
            { ClickCount: First(colExistingRecord).ClickCount + 1 }
        ),
        Patch(
            ButtonClicks, 
            Defaults(ButtonClicks), 
            {
                UserEmail: User().Email,
                ClickDate: Today(),
                ClickCount: 1
            }
        )
    );
    
     
    Label Property
     
    Sum(Filter(ButtonClicks, ClickDate = Today()), ClickCount)
     
  • Verified answer
    MS.Ragavendar Profile Picture
    2,779 Super User 2025 Season 2 on 18 Mar 2025 at 12:15:04
    Count Button Clicks
    Approach 1: Using a SharePoint List 
    • Create a SharePoint List name 'Button Clicks' with columns (UserEmail,ClickDate, Count)
    • Button (OnSelect) Enter the Patch Code.
    •  This logs each click separately with the user’s email and date.
    Patch(
        ButtonClicks, 
        Defaults(ButtonClicks), 
        {
            UserEmail: User().Email,
            ClickDate: Today(),
            ClickCount: 1  // Each press is logged separately
        }
    )
    
    Total Clicks for the Day
     
    Insert a label or Textbox control and filter the records based on the date as shown.
     
    CountRows(Filter(ButtonClicks, ClickDate = Today()))

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item
     
  • Suggested answer
    Gabriel G. Profile Picture
    742 Super User 2025 Season 2 on 18 Mar 2025 at 12:14:35
    Count Button Clicks
    Hi,
     
    Like @Pstork1 mentioned, there is no way to keep a variable through multiple instances of an app. Anyway, it is not a big deal to keep an increment integer somewhere in a db.
     
    If your button simply create records, you probably already have that value hidden in your db since you can simply calculate how much records is created between Today@00:00 and Today@23:59.
     
    I hope it helps!
    ____________________________________________
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
  • Kmayes Profile Picture
    786 on 18 Mar 2025 at 11:25:50
    Count Button Clicks
     
    I thought the complexity would be the multiple users accessing. I wondered if it was easier to add an item to a list which then in hand would capture the details, but was hoping there would be a slicker way of doing so without excess building
  • Suggested answer
    Pstork1 Profile Picture
    67,170 Most Valuable Professional on 17 Mar 2025 at 16:47:54
    Count Button Clicks
    You can easily add a formula to increment a counter variable in the button's onSelect.  The hard part is that that variable is only available in that one user's app.  So you'll also need to retrieve the current value from a data source somewhere, increment that and patch it back if you want multiple users.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     

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