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 / How to update gallery ...
Power Apps
Answered

How to update gallery total items count label after deleting an item ?

(0) ShareShare
ReportReport
Posted on by 85

 

 

 

 

Currently building a simple ticketing app. 
As you can see the main page has:

Gallery containing tickets

Labels for total tickets, open tickets, and closed tickets (located within this screen OnVisible)

 

When I delete a ticket, the labels with Total tickets won't update (it only updates if I navigate to another screen, then back). See example below. I had 3 tickets, I deleted 1 ticket, but the labels with total did not update.

 

FLOWPA_0-1641919365583.png

 

Can the label with total be refreshed and updated when a gallery item is deleted?

 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @FLOWPA 

    What are your formulas on the Text properties of the labels?

    They should be CountRows(yourGallery.AllItems based.

  • FLOWPA Profile Picture
    85 on at

    @RandyHayes

    The screen OnVisible sets the variables for the totals:

    ClearCollect(coll_GallTickets_All, Gall_TicketsList.AllItems); //ALL GALLERY ITEMS
    Set(var_Ticket_CountTOTAL, CountRows(coll_GallTickets_All));

     

    Labels all have Text set as: "Total Tickets: " & var_Ticket_CountTOTAL


    @RandyHayes wrote:

    @FLOWPA 

    What are your formulas on the Text properties of the labels?

    They should be CountRows(yourGallery.AllItems based.


    I tried your solution and it works, thanks for your reply.

    Is there anyway I can assign variables instead? Something similar to my current setup.

     

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @FLOWPA 

    Yes, so get rid of all that stuff.  Variables and Collections (table variables) are all snapshots.  Use them only when you need snapshots of values.  Otherwise, let your controls derive their values with the formulas you provide them.

     

    Also in general, you would want to avoid duplicating your data in the app.  Your collect statement is taking a table that is in AllItems and creating an exact duplicate of that in a collection table.  First, this will be a snapshot at that time only.  Then your Set is just counting the rows of the table (collection).

    So...to simplify, CountRows can count the rows of ANY table...and AllItems is a table. 

    Then your Label Text is just CountRows(Gall_TicketsList.AllItems)

     

    If you want to determine status (I notice you have an Open and Closed label), then just filter on a value in your Gallery items.

    ex. If you have a "Status" column with either "Open" or "Closed" in it, then the Open label Text property would be:

       CountRows(Filter(Gall_TicketsList.AllItems, Status = "Open"))

    And your Closed count label Text property would be:

       CountRows(Filter(Gall_TicketsList.AllItems, Status = "Closed"))

     

  • FLOWPA Profile Picture
    85 on at

    @RandyHayes thank you! 
    Now, all the labels with CountRows are refreshing instantly.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard