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 / Patch() against Excel ...
Power Apps
Answered

Patch() against Excel workbook returns error

(0) ShareShare
ReportReport
Posted on by 332

I am finishing up my self contained Test Drive version of our company's PowerApp, so i have to keep all data local.

 

So far i'm having no trouble with Collect(), but in some cases, I'd like to explore persisting data in Excel.

 

however, when i use code like this:

 

UpdateContext({row: First(Filter(Data, Datum="SafetyTeam"))});
Patch(
 Data,
 row,
 {Value: row.Value + 1}
)

 

I get an errors like this:

 

"The first argument of 'Patch' should be a collection" (No, according to the docs, it should be a Data Source)

"The type of this argument 'Value' does not match the expected value of 'Hyperlink.'" Found type 'Number'. (really, well this code does not report that last error (SafetyIndex here is, indeed, a collection)

 

UpdateContext({rec: First(Filter(SafetyIndex, Label = "Member"))});
Patch(
 SafetyIndex,
 rec,
 {Weight: rec.Weight +1}
);

)

 

 

rookie error (again)?

 

Categories:
  • v-yamao-msft Profile Picture
    Microsoft Employee on at

    Hi Mcorning,

     

    My understanding is that you want to save data to Excel table by using Patch function.

     

    So I tried your code on my side, it worked and data can be saved to my Excel table.


    My table is saved on Dropbox, and I configured the code looks like below. When I click the button to save data, it worked as expected.The code I am using is:

    Patch(Student,First(Filter(Student,Name="aaa")),{RA2:First(Filter(Student,Name="aaa")).RA1+1})

    OR

    UpdateContext({test:First(Filter(Student,Name="ddd"))});Patch(Student,test,{RA2:test.RA1+1})

     

     If possible, please provide more details of your scenario.

     

    Best regards,
    Mabel Mao

  • mcorning Profile Picture
    332 on at

    Ah, there's the difference: you use Dropbox to access your workbook, i used "Add static data to your app" option in Add Data Source.

     

    I am building a Test Drive version of our app for AppSource, so i cannot take any external dependencies.

     

    So please repro using the same Data Source that i am.

  • v-yamao-msft Profile Picture
    Microsoft Employee on at

    Hi Mcorning,

     

    Thanks for correcting me.


    I tried the option “Add static data to your app”, create a connection to the Excel table saved on local.
    Then when I used Patch or Update function with the similar code, I got the same error message with you, “The first argument of ‘Patch’ should be a collection”.
    I haven’t found any related documentations on “Import from Excel”.
    I am trying to collect this from my side and I will back to you once I got a response.


    Thank you for your feedback and understanding.

     

    Best regards,
    Mabel Mao

  • mcorning Profile Picture
    332 on at

    roger. thanks a 0xF4240. eager for news. lives depend on this working...

  • Verified answer
    v-yamao-msft Profile Picture
    Microsoft Employee on at

    Hi Mcorning,

     

    I have some updates for you.


    Currently, Excel Static connection is read only. We are not able to write new data to it.
    Please see this thread about “Patch function not working with local data source” for a reference:
    https://powerusers.microsoft.com/t5/PowerApps-Forum/Patch-function-not-working-with-local-data-source/m-p/17279#M7444

     

    Best regards,
    Mabel Mao

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 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard