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 / Help understanding dyn...
Power Apps
Answered

Help understanding dynamic increment

(0) ShareShare
ReportReport
Posted on by 62

Hi

While looking for a way of adding a dynamic increment to my repeating gallery, I came across this solution:

 

https://powerusers.microsoft.com/t5/Building-Power-Apps/powerapps-dynamic-increment/td-p/299063

 

So I implemented it and it worked as a charm (except for a couple of adjustments I had to make because of my environment)

The thing is
I have no clue whats going on there.

Why on the close button we need to create a new collection from scratch with the same fields as the main one, if we are only going to use it inside this Close button functionality? What's the purpose of it?
And why are we doing a Clearcollect afterwards?

Categories:
  • timl Profile Picture
    37,407 Super User 2026 Season 2 on at

    @Morke 

    Can you confirm which formula you're referring to when you say the 'close button'?

    Are you referring to the formula for the remove icon, as shown below?

    -------------

    Within the Gallery, add a "Remove" icon, set the OnSelect property to following:

    Remove(RecordsCollection, ThisItem);
    Clear(RecordsCollection1);
    ForAll(
    RecordsCollection,
    Collect(RecordsCollection1, {Name: "Details-"& CountRows(RecordsCollection1)+1, TextBoxValue: TextBoxValue})
    );
    ClearCollect(RecordsCollection, RecordsCollection1)

     

  • Morke Profile Picture
    62 on at

    @timl Yes, exactly, that formula.
    Why is he creating a new collection only to be used there, in that formula?

  • Verified answer
    timl Profile Picture
    37,407 Super User 2026 Season 2 on at

    @Morke 

    The code sample that you refer to here accounts for the fact that the end user can remove an item in the gallery by clicking the remove icon.

    In this instance, we need to renumber the items in the gallery because there will be one less item. That is the purpose of this code.

    Hope that makes sense.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard