cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
plebhead22
Frequent Visitor

Writing edits and additions to a place other than the datasource

I have a canvas app built on the samples provided.

The datasource used is a table in Excel that has been created via a PowerQuery.

Edits and additions all work well. That is until I refresh my PowerQuery and everything is wiped out back to how it was before the edits, which is logical.

The PowerQuery has to be refreshed frequently because the data is of project numbers and descriptions that will keep growing.

What I would like to do is be able to write the edits and additions to a separate datasource. I can not figure out how to do this.

If they are written to a different datasource that can be merged into the PowerQuery and will not be affected by a data-refresh.

I have been trying to figure out if the Patch function will work.

Hopefully my problem makes sense!

Any guidance will be appreciated.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @plebhead22 ,

Do you mean that the data in your Excel table is pulled from other data source using Power Query?

Which data source does your Excel table pull data from?

Further, do you add your Excel table as data source within your app, and want to update the data within it using PowerApps?

 

Based on the operation that you made, I think you have some misunderstanding on PowerQuery functionality in Excel. The PowerQuery functionality in Excel is used to pull data from external data source into current Excel table. When you refresh your PowerQuery in Excel, it would re-load data from external data again.

In other words, if you made some changes within your Excel table, it just affect your Excel table itself rather than the underlying data source (which your Excel table pull data using PowerQuery from). When you refresh PowerQuery, the data within your Excel table would be overrided with data from the underlying data source again.

 

As an fixed solution, please consider take a try to add the underlying data source (which your Excel table pull data using PowerQuery from) as data source within your app, then made changes to the underlying data source (rather than your Excel table) using your app.

More details about adding data source within an app, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/add-data-connection

 

If you want to update the underlying data source using Patch function, please take a try with the following workaround:

Patch(         /* <-- Add new record to data source */
         'YourDataSource',
          Defaults('YourDataSource'),
          {
               Column1: "xx",
               Column2: "xx",
               ...
          }
)
Patch(                  /* <-- Update an existing record in your data source */
          'YourDataSource',
           LookUp('YourDataSource', PrimaryKeyColumn = "xxx"),   /* <-- Find the record you want to update based on PrimaryKeyColumn in your data source */
           {
             Column1: "xxx",
             Column2: "xxx",
             ...
           }
)

More details about Patch function, please check the following article:

Patch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @plebhead22 ,

Do you mean that the data in your Excel table is pulled from other data source using Power Query?

Which data source does your Excel table pull data from?

Further, do you add your Excel table as data source within your app, and want to update the data within it using PowerApps?

 

Based on the operation that you made, I think you have some misunderstanding on PowerQuery functionality in Excel. The PowerQuery functionality in Excel is used to pull data from external data source into current Excel table. When you refresh your PowerQuery in Excel, it would re-load data from external data again.

In other words, if you made some changes within your Excel table, it just affect your Excel table itself rather than the underlying data source (which your Excel table pull data using PowerQuery from). When you refresh PowerQuery, the data within your Excel table would be overrided with data from the underlying data source again.

 

As an fixed solution, please consider take a try to add the underlying data source (which your Excel table pull data using PowerQuery from) as data source within your app, then made changes to the underlying data source (rather than your Excel table) using your app.

More details about adding data source within an app, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/add-data-connection

 

If you want to update the underlying data source using Patch function, please take a try with the following workaround:

Patch(         /* <-- Add new record to data source */
         'YourDataSource',
          Defaults('YourDataSource'),
          {
               Column1: "xx",
               Column2: "xx",
               ...
          }
)
Patch(                  /* <-- Update an existing record in your data source */
          'YourDataSource',
           LookUp('YourDataSource', PrimaryKeyColumn = "xxx"),   /* <-- Find the record you want to update based on PrimaryKeyColumn in your data source */
           {
             Column1: "xxx",
             Column2: "xxx",
             ...
           }
)

More details about Patch function, please check the following article:

Patch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Many thanks

Editing the true source is something I had not considered - before it goes into PowerQuery - that makes perfect sense.

I will give that and Patch a try.

 

Thnaks for your time and help.

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (3,076)