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 :
Power Platform Community / Forums / Power Apps / Increment gallery records
Power Apps
Unanswered

Increment gallery records

(0) ShareShare
ReportReport
Posted on by 37
The code below works fine and increments rows from a collection connected to a gallery. I want to have it increment up until a title row and then reset to 1 on the first row after the title. The title data will be blank on the rows it needs to increment: 
 
Please modify:
 
ClearCollect(
    editTable,
    ForAll(
        Sequence(CountRows(editTable)),
        Patch(
            Last(FirstN(editTable, Value)),
            {RowNumber: Value}
        )
    )
);  
Categories:
I have the same question (0)
  • Suggested answer
    ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    Increment gallery records
    Create a new variable incrementValue set it to 1 before the ClearCollect
    You are still incrementing using Value but setting the increment to the record based on the new incrementValue variable
    You reset the incrementValue based on your condition back to 1. Not sure what you meant by after so you may have to move where you do the reset and reset to 0 instead then increment.
    The syntax is a bit off I am not typing on my desktop and I don't know exactly the condition you are checking for.
     
    Something like this should work
     
     
    UpdateContext({incrementValue: 1});
     
    ClearCollect(
        editTable,
        ForAll(
            Sequence(CountRows(editTable)),
            If(titlerowvaluecheck,UpdateContext({incrementValue: 1}));
            Patch(
                Last(FirstN(editTable, Value)),
                {RowNumber: incrementValue}
            );
            UpdateContext({incrementValue: incrementValue + 1});
        )
    );  
  • geraldc1820 Profile Picture
    37 on at
    Increment gallery records
    Thank you. That concept makes sense but PowerApps will not allow variables set inside a ForALL.
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    Increment gallery records
    Didn't realise that.
     
    Instead of using a variable we can try using a table with patch.
     
    Set(incrementTable, Table({valueIncrement:1}));
     
    Patch(incrementTable, First(incrementTable), { valueIncrement:First(incrementTable).valueIncrement + 1 })
     
    Replace as appropriate and see if it works. I am assuming that Patch does not execute concurrently and ForAll waits for the completion.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 836 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 231 Super User 2025 Season 2

Last 30 days Overall leaderboard