web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to update all gall...
Power Apps
Answered

How to update all gallery records fast

(1) ShareShare
ReportReport
Posted on by 299 Moderator
I have a set up to display questions for an exam 
 
More than 60 questions are displayed in a gallery, the teacher has to edit occasionally 5 or 10 rows for an existing exam, depending on whether they forgot to add data
 
The usual patch is very slow, it seems I have to scroll up and down so it can 'read' all the records, is there a more efficient way? 
 
I tried Matthew's solution but it doesn't seem to do it at all, I guess it doesn't have the gallery data so unsure how it would be able to do it 
 
 
Current code
 
// Update each question's 'Actual Score' and 'Comments' in the Question's table
ForAll(
    questions_gal_2.AllItems As Record,
    Patch(
        'Questions',
        LookUp('Questions', 'Questions Id' = Record.'Questions Id'),
        {
    'Actual Score': Record.score_cmb.Selected.Value,
    Comments: Record.comments_txt.Text
        }
    )
);
Categories:
I have the same question (0)
  • Suggested answer
    KeithAtherton Profile Picture
    3,705 Most Valuable Professional on at
    Hey. I've used the schema match approach mentioned in Matthew Devaney's article before which has given the best performance I've seen so far.
     
    I think it could be adapted to retrieve all rows from the gallery (questions_gal_2.AllItems) then perform the schema match approach instead of using the ForAll loop.
  • Verified answer
    Mark Nanneman Profile Picture
    991 Super User 2025 Season 2 on at
    Hello, a few comments:

    A. Non Powerapps Solutions:
    What kind of data source is "Questions"?  If it's in SharePoint you could just go to that list in SharePoint, filter it how you like (or create a View) and click "Edit in grid view", then you can edit the datasource almost like you're in Excel.  There are similar things you can do if the datasource is in Dataverse.

    B.  Speed up your "For All"
    You could speed up your "ForAll" significantly by removing the "LookUp" part.  That's almost certainly redundant and slowing it down.  Just try replacing that whole LookUp function with "Record".  Doing a lookup to get the record that you already have in your "ForAll" can almost double the time it takes to do each item in your "ForAll".

    C.  The Batch Patch Method
    You could use the method described by Matthew Devaney but you'd have to somehow collect an updated version of each item (with at least the Key column(s) and the columns you want to update) and then Patch that collection to the datasource.

    D.  Why not just update as you edit each item?
    That said, If all you're doing is patching two simple columns, a score and a comment field, why not just patch those updates as they're entered?  The user would probably hardly notice.
     
    You could either have "OnChange" Patches for the controls in your gallery, something like putting "Patch(Questions, ThisItem, {'Actual Score': Self.Selected.Value})" in the "OnChange" of the score_cmb control, or you could add a simple form that uses the selected question from the gallery as its item.  Then you can add the score and comment field to display/edit on the form, and add a submit button.

    If this helped you, please click "Does this answer your question" and give it a like to help others in the community (+ close the ticket)!

    Power Platform Developer | LinkedIn: Mark Nanneman | Blog: Power Stuff  | YouTube: Mark's Power Stuff  | 

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard