Reputation: 177
I am struggling with what must be easy for most of PowerApps devs.
I have an Excel Table "Table1" used as a Datasource in my PowerApps application and I want to update each row of the collection with a formula : ColumnX = ColumnY.
No gallery, no collection here. I haven't created my own ID as I didn't need it.
I tried with ForAll and Patch functions without any success in finding the correct syntax...
ForAll(ShowColumns(Table1,"Avancement antérieur (%)","Avancement total (%)"),
Patch(Table1, ThisRecord, {'Avancement antérieur (%)':'Avancement total (%)'}))
Thanks for your help!
Upvotes: 0
Views: 2007
Reputation: 177
I ended up with this solution, with a filter applied :
ForAll(
Filter(Table1, Not(IsBlankOrError('Avancement total (%)'))),
Patch(Table1, ThisRecord, {'Avancement antérieur (%)':'Avancement total (%)'}, {'Avancement total (%)': ""}))
Upvotes: 0
Reputation: 87228
You didn't create an ID, but when you use an Excel table as the data source for an app, an ID is created for you automatically. When you used the ShowColumns function to select only the two columns that you wanted, you "removed" the id from the table that is passed to the ForAll function (notice that this removal is only done in memory; the original table still has all of its columns). When that id is removed, the Patch function will now know which record to update, so it ends up creating new ones.
To preserve the id, you can store the value of your table in a local collection, and use that collection as the parameter to ForAll:
ClearCollect(tempCollection, Table1);
ForAll(
tempCollection,
Patch(
Table1,
ThisRecord,
{ 'Avancement antérieur (%)': 'Avancement total (%)' }))
Upvotes: 1