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 Patch multi-rec...
Power Apps
Answered

How to Patch multi-records

(0) ShareShare
ReportReport
Posted on by 29

Hi,

 

I have build a PowerApps solution to update the status of a column in a Sql Server database.

On a Power BI report, my users filter items and when they have selected the data they want, they use the PowerApps canvas to update what they have selected.

To communicate between Power BI and PowerApps, I have used the great functionnality PowerBIItegration.Data.

 

Here is my problem.

In order to update only the records selected, I have used the Patch function because I can include a test. But maybe there is another function to update my table.

And after many research, I have found how to write the code to update one field of my table and I did that

Patch('[dbo].[ImportTable]',
First(Filter(
'[dbo].[ImportTable]',
'DOC ZIPPE' = OT.Text)),
{StatusColumn: true })

 

Sure, it works but only for the first record (logic, the Filter function is included in a First function)

I have tried to adapt the code with ForAll but without success.

 

How can I write the code to update many records?

 

Thanks in advance

Categories:
I have the same question (0)
  • FredLEGUEN Profile Picture
    29 on at

    Here is my new code with LOOKUP this time but I still update one record, not all selected

    😒😤😤😤


    ForAll(PowerBIIntegration.Data,
       Patch('[dbo].[ImportData]',
          LookUp(
          '[dbo].[ImportData]',
          'DOC ZIPPE' = OT.Text
       ),
       {StatusColumn: true}
       )
    )

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

    @FredLEGUEN 

    What is OT.Text  in your Formula?

    You should be referencing a value that will be in your PowerBIIntegration.Data list that will provide a unique record to be returned in your Lookup.

     

    For example, if the PowerBIIntegration.Data has a column called DocID, then your formula would be similar to this:

    ForAll(PowerBIIntegration.Data,
     Patch('[dbo].[ImportData]', 
     LookUp(
     '[dbo].[ImportData]', 
     'DOC ZIPPE' = DocID
      ),
     {StatusColumn: true}
     )
    )

    See if that is what you are running into.  If you are basing OT.Text on a label on your screen, then you will only be getting one record patched.

     

    I hope this is helpful for you.

  • FredLEGUEN Profile Picture
    29 on at

    Thanks @RandyHayes for your answer,

    You describe perfectly the problem but I don't get your solution.

     

    OT is the name of my Label where I display the contain of the column 'DOC ZIPPE' of my database.2019-06-12_16-18-24.png

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    And the gallery is linked to the database

     

    2019-06-12_16-19-26.png

     

     

     

     

     

     

     

     

     

     

     

     

     

    The contain of my column 'DOC ZIPPE' is already unique (it's my column Key in fact).

    This is why I have written OT.Text because each row in the gallery is unique.

    So, in my formala, I have created a test between the column of my table 'DOC ZIPPE' and the value of the gallery list OT.TEXT

     

    I hope these informations could help to correct my formula. Because DocID, I don't understand where it can come from ?

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

    @FredLEGUEN 

    Ah, the picture sheds the light!

    What you really want to iterate over in your ForAll statement is the Gallery items.

     

    Consider using this formula instead:

    ForAll(GalleryOT.AllItems,
     Patch('[dbo].[ImportData]', 
     LookUp(
     '[dbo].[ImportData]', 
     'DOC ZIPPE' = OT.Text
     ),
     {StatusColumn: true}
     )
    )

    That should give you what you want assuming that the 'DOC ZIPPE' is a text column.  

  • FredLEGUEN Profile Picture
    29 on at

    Thanks you so much @RandyHayes 

    That's exactly how to solve the problem.

     

    I knew I was close to the solution but the documentation is really poor about PowerApps (the application is too new).

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    Just what I was looking for after struggling for a couple of hours. Thank you for the solution @RandyHayes  and for @FredLEGUEN  for raising the question.

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
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard