The Power Apps visual is a powerful tool for adding writeback and other functionality from Power Apps into Power BI reports. This visual makes it possible for users to take action directly from Power BI reports and update the data in real time from the reports which then can be immediately reflected back in the reports. This ability to edit data directly from a Power BI report, brings another layer of functionality to Power BI reports that was not previously possible.

The Power Apps visual first became available as a custom visual in 2018 and then as one of the default visuals as of the October 2019 release of Power BI Desktop.
The Power Apps visual provides an important functionality to refresh a Power BI report page automatically which eliminates the need for the end user to manually refresh the page by clicking on the Refresh option from the Power BI menu to see changes in the data.
In this post, I will show you how to add a simple app to a Power BI report to update the data in the report and have the app automatically refresh the page. All of this can be done with a few lines of code thanks to all the work that has been done in Power Apps to make the app creation experience extremely user friendly and relatively easy to learn.
Design
Before we get started, let’s take a look at the overall design. Our goal is to create a Power BI report and add a Power Apps app (referred to as “app” for the rest of this post) so that we can update the report’s data and have the page refreshed automatically to reflect the changes we make.
In order for the page refresh to reflect the changes immediately, the table being updated by the app, must have its storage mode set to DirectQuery. If its storage mode is set to Import, the changes won’t be reflected with a page refresh in Power BI service until the dataset (data imported in the model) is updated by a dataset refresh. To read more about table storage modes, see this.
Process
Step 1: The user makes some selections in the Power BI report which provides context (current filter and row selections) to the app. This way the app can have some fields prefilled so that when the user wants to update records, the user does not have to type everything form scratch.
Step 2: The user submits the updates by clicking on a button(or icon) in the app. This will update the underlying SQL table.

Step 3: The app triggers a page refresh through a function called PowerBIIntegration.Refresh(). This function is the key to this design. In fact, the Power Apps have been available for use in Power BI for a while, but the integration part is a new feature (within the last year) and takes their usefulness to a whole new level.
Step 4: Once the page is refreshed, the user will see newly updated data reflected in the report.

Data Source
The examples shown here are based off of the AdventureWorksDW sample database. I added a sample sales table based on FactInternetSales. To keep things simple, this table has all the fields that the report needs. It does not contain any foreign keys to other tables. This way the focus of this post can remain on the report/app integration. (To learn more about setting up an app that uses more than one SQL table, see this post by Brian Knight.)
CREATE TABLE [dbo].[FactSmallSales]( [SalesOrderNumber] [nvarchar](20) NOT NULL, [SalesOrderLineNumber] [tinyint] NOT NULL, [ProductName] [nvarchar](250) NULL, [ProductSubcategoryName] [nvarchar](250) NULL, [CustomerName] [nvarchar](250) NULL, [SalesAmount] [money] NULL, [OrderDate] [date] NULL, ) ON [PRIMARY] GO ALTER TABLE [dbo].[FactSmallSales] ADD CONSTRAINT [PK_FactSmallSales] PRIMARY KEY CLUSTERED ( [SalesOrderNumber] ASC, [SalesOrderLineNumber] ASC )WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY] GO
This table has a primary key on SalesOrderNumber and SalesOrderLineNumber. I will explain later why this is needed for the simple app to work. You can work with a table without a primary key in Power Apps but you have to do more work to update it vs. if you work with a table that has a primary key.
Insert into [dbo].[FactSmallSales] Select top 1000 SalesOrderNumber, SalesOrderLineNumber, EnglishProductName as ProductName, dpsc.EnglishProductSubcategoryName as ProductSubCategoryName, dc.LastName + ', ' + dc.FirstName as CustomerName, SalesAmount, OrderDate from [dbo].[FactInternetSales] fs Join DimProduct dp on fs.ProductKey = dp.ProductKey join DimProductSubcategory dpsc on dpsc.ProductSubcategoryKey = dp.ProductSubcategoryKey join DimCustomer dc on dc.CustomerKey = fs.CustomerKey
Power BI report
Once you have the FactSmallSales table ready, open Power BI Desktop and use Get Data to point to the FactSmallSales table. When prompted for storage mode, make sure you choose DirectQuery; otherwise the refresh won’t work as expected. Note: The model can have other tables in Import or Dual storage modes but the table to be updated must be in DirectQuery.
The following picture shows a sample report I created. I have one chart showing Sales by ProductSubCategory and a card showing total sales. The table visual at the bottom shows details of FactSmallSales.

At this point, it is very tempting to click on the Power Apps visual from the visualizations and add it; however, it is very important that you follow the recommended order of operations and deploy the report to Power BI service first.
After you add the visual in the service and connect it to a Power Apps app, you can download a copy to your machine and save it. Even then, the Power Apps visual cannot refresh a page in Power BI Desktop. The page refresh only works in the service.
Make sure to deploy the report to Power BI service first.
Adding a Power Apps app
Once you open the report in Edit mode in Power BI service, click on the Power App visual.

The visual provides very clear instructions on how to configure it.

First select the fields you want to make available to the app. In this case, select all the fields from FactSmallSales since we want the user to be able to edit all the fields in this table.
This next step is critical. You are given a choice of using an existing app or creating a new one.

A new app will always work properly for both data integration between the Power BI report and the app as well as the automatic page refresh by the app.
The existing apps fall into two categories and only one will work properly for the page refresh. If you watch videos posted online, you will see that some people can get an existing app to work while others say that you must create a new app.
- An existing app only works if it were previously created from the Power BI service.
- An existing app that was not previously created from Power BI will not integrate properly with Power BI. If you try to use such an app, Power BI will actually open the app and make some changes and it appears that it is going to work but even if you get the data integration part to work by manually adding some code, the page refresh will not work. The PowerBIIntegration.Refresh() is not available for apps previously created in Power Apps.
The moral of the story is: Always create a new app or use an app that you have previously created from Power BI service.
Here we will create a new app. To continue, click on Create New. This will open Power Apps Studio with a newly created app. The app has one screen with a Gallery on it that shows one item per row of FactSmallSales. You can preview the app by clicking on the play button on the top right corner of the studio.

As you can see, you already have a fully functional app showing one field (Customer Name) from the table. At this point, if you save the app and go back to Power BI, you will have an app that will interact with the report. If you click on the bar chart in the report, the app will show the customers for that ProductSubCatergory. This works because Power BI is passing context to the app.
In Power Apps Studio, take a look at what is created for you. On top of Screen1, you see PowerBIIntegration. This is the connector that makes it possible for the context to flow from Power BI to the app.
If you take a closer look at the Gallery, you will notice that its Items property is set to ‘PowerBIIntegration’.Data.

Let’s make some changes to the app to make it more useful and be able to update some records.
First let’s work on the Gallery. A gallery is very easy to work with. You make changes to the first item in the Gallery and the rest of it will mimic the changes. In this case, you can drag the bottom of the first item to make it larger and then copy and paste the Customer Name field several more times. Since each item in the gallery gets its data from the source of the Gallery (in this case PowerBIIntegration.Data), you can change the source for each field from CustomerName to a new field by modifying its Text property. There is inttelisence built in that helps you choose the fields.

The following picture shows how I designed the first tile of the Gallery.

Next we need to add a second screen to edit selected items from the Galley. Go to the Home tab and click on New Screen and choose Form.

This creates a new screen with one Form for editing. To learn more about Forms in Power Apps see this.
A form has two important properties:
- Data Source: This is the table that will get updated.
- Items: This is where the form gets its fields populated from.
Note: Even though the fields are already coming from the Power BI report, you must connect the form to your SQL data source for it to be able to write changes back to the table
To set the Data Source, click on the Connect url in the form. This will guide you to create a new connection. Choose SQL database and connect to FactSmallSales.

(Reminder: If you are working with an On-premises database, you need to have an entry for the database in the On-premises Data Gateway)
Once you make the new connection, choose the connection in the Data Source drop down. Next click on Edit Fields and choose all the fields. The order you click on the fields is the order in which they will be added to the form. You can change that later from the Fields window.

At this point, you get a nice screen with a form with all the fields on it but the form is empty. To get the form to prepopulate from the selected item from the Gallery from the other screen, you need to set the form’s Items property. With the form selected, find the Items property and set it to Gallery1.Selected. This will populate the form.

You can change the title of the form by clicking on it. Change it from “Title” to “Edit Sales Order”.
So far we have a form that is showing the selected item from the Gallery. Let’s get the form to save its values to FactSmallSales. If you click on the checkmark icon on the top right corner of the form, you will see that Power Apps has added a line of code to its OnSelect property:
SubmitForm(EditForm1)
This one line of code is all you need to save the data back to the table! This is amazingly simple! This function works well if you have a primary key on the table. You can add more advanced code for error handling and other cases where you want to update many records at once (See Patch), but this one line of code is sufficient when you are working with one table with a primary key.
Once the data is saved, we want the app to refresh the Power BI report and the app to navigate to the first screen. Modify the OnSelect property to look like this.
SubmitForm(EditForm1);PowerBIIntegration.Refresh();Navigate(Screen1);

PowerBIIntegration.Refresh() is what refreshes the page. (If you get red squiggly lines under this function, you are most likely editing an old app that cannot refresh the page.)
Navigate is a is very simple function and self explanatory. You can read more about it here. It lets you move between screens.
The last thing left to do on this screen is to set the OnSelect property of the X icon to let the users cancel out of the edit form if they change their mind. Set the OnSelect property of the X icon to Navigate(Screen1).
This finishes our work on the second screen. The last step left is to add a way for users to navigate from Screen 1 to Screen2.
On Screen1, select the gallery. Click no the “>” icon on the first item in the gallery. Set its OnSelect property to Navigate(Screen2).

To make the first screen look nicer, you can add a header to it. The easiest way to do this is to select the header from Screen2 and copy it over to screen 1 and change its text to “Sales Orders”.

You are almost ready to use the app in your Power BI report. You must first save the app and publish it. Go to File and choose Save and follow the instructions.
The creator of the app gets access to the app by default. If you want other users to use the app, you must give them access by sharing it.

Now if you go back to your Power BI report, the Power Apps visual will load your app. You report will look like this:

Select the first item from the Gallery and click on the “>” icon to go to the Edit screen. Change its ProductSubCategory to “Test Bikes” and change its sales amount to 327800.27. Click on the checkmark icon to save the changes.

Your report will update to reflect the changes. You will have a new bar in the chart for “Test Bikes” and the SalesAmount shown in the card updates to $4M.

This is a very useful feature for users who want to analyze data and update data all from Power BI.
Future app changes
As long as you keep the Power BI report and the Power Apps windows open, you can go back and forth between them and make changes to the app and see the changes back in the report once you save the app.
If you make a change to the app and don’t see your changes immediately in the Power Apps visual, save the report, close it and reopen it.
For all future edits to the app, you should start the process by editing the Power BI report and then editing the Power Apps visual to get to the Power Apps studio. This is required if you are adding new fields to the app. Additionally, this way you will have data in the Power Apps studio while you work on the app.
Limitations
The Power Apps visual has some limitations.
- In order to add new fields to the app, the app must be edited from Power BI Service after changes to the Power BI report fields.
- Can’t trigger a refresh of Power BI reports from Power BI Desktop.
- Can’t filter a Power BI report. It receives context from a report but cannot send context back.
- Not supported in Power BI Report Server.
Always Publish the report to PBI Service first.
Summary
The order of operations matter to get the automatic page refresh to work:
The following shows the different scenarios I tested with the results:
Report Created In Power BI Desktop | Report Published and Edited In Service | New App from Power BI Service | Existing Power App Not Created from Power Apps visual | Existing Power APP Created from Power Apps visual | Page Refresh Works? |
Yes | No | – | – | – | No |
Yes | Yes | Yes | Yes | ||
Yes | Yes | – | Yes | – | No |
Yes | Yes | – | – | Yes | Yes |
To summarize:
- You must first publish the report to the service, open the report from the web interface and edit it.
- Add the Power Apps visual.
- Select fields to add them to the visual.
- Follow the visual’s instructions.
- Save and share the App.
Download Sample Code
I have uploaded the Power BI report and app that I used for this post to my GitHub repository. Once you open the reports, you must go to Edit Queries –> Data Source settings or follow the prompts if you click on Apply Changes to point the reports to your database. Similarly you have to connect the Power Apps sample app to your database for it to start working. Go to Screen2 and click on the Connect url on the form and follow the instructions.
any possibility that write back can happen from embed power BI report. I am looking for something similar to embed power BI for Power App also. Reason is very simple our customers don’t want to login to our our Web app then again to Power App. I am looking for this feature for long time, this will open up large number of opportunities. Microsoft, PLEASE GIVE ME EMBED POWER APP
This is a good question; however, I have not worked with embedded Power BI reports in Power Apps itself. My guess is that the writeback will happen but I am not sure about the page refresh.
Thanks for the great guide.
I tired to follow but when I try to make connection to SQL – I got MSG that it’s premium only feature.
I remember that in the past I succeed to connect to SQL.
Can you please let me know if you have premium or maybe I done something wrong.
Nir, you need to have a license for Power Apps. See this link: https://docs.microsoft.com/en-us/power-platform/admin/pricing-billing-skus
For testing purposes, you can get a Community Plan (https://powerapps.microsoft.com/en-us/communityplan/) This is what I use. Hope this helps.
Thank you for sharing. This is amazing.
I have a very similar use case but I am not allowed write data to my existing table. I don’t have any choice but to create another table for write back and perhaps join it back to the existing table in power bi using foreign key (member_id). Do you know if this is possible? Now sure to Copy data from table 1 to table 2 to get my foreign key. Below is some additional info about my tables
Table 1:
Pre-populated table with member level data (name, id, location, etc.)
Table 2:
A currently empty table for Write-back where users of the report will enter feedback about members in table 1. Columns in this table are:
Member_ID (to be pulled automatically from table via power apps, if possible),
Feedback_By (to be pulled for the user logged into power bi via power apps gallery),
Feedback_Date (to be entered automatically based on current time),
Feedback_Text (this will be free text entered manually by user)
I’d really appreciate your thoughts on this?
Regards,
Sal
This post shows you how to update any single table which can be Table 2 from your example. If Table 1 and Table 2 are both in your model and connected properly with relationship, you should be able to see the updated comments along with the rest of data from Table 1. Hope this helps.
Thank you, that really helps. Does power apps allow copying member_id from table 1 over to table 2? I wouldn’t want end user to enter a member’s name or id manually in the form to avoid data entry errors. This way I can also have the validated member_ids added to table 2 for connecting to table 1 via relationship.
Sal, for more complex update statements look into the Patch function. https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch
Additionally, I wouldn’t be allowing users to ‘update’ existing data but only add new data. Is that also possible?
Yes, you can add an additional screen that only adds records. If you go to Create.PowerApps.Com and click on Create and choose SQL from under “Start From Data”, it will create a sample app for you that has an Update and an Insert screen in it. Check out the last screen it creates to add data. Make sure you use a table with a primary key for this sample app to work.
Hi Shabnam,
Thanks for sharing this amazing tip. I have a similar need where I have to write back to SQL Server a entire table from a PBI dataset.
Do you know if there is a way to do that ? Thanks.
Douglas
Douglas,
For more complex updates, including entire table updates, you need to look into the Patch function. https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch
Thank you very much, so cool! I noticed that by default the app is created in phone format, is it possible to create apps in Tablet format? or to modify to the tablet format?
Aviv, if you go to App Settings (File –> Settings) , one of the tabs is called “Screen Size + Orientation”. You can switch the layout to Landscape which works better for Tablets.
Thanks Shabnam! I did managed to change the layout.
One more question – once I have the PowerApp configured as in this article the filter context passes from the PowerBI dashboard to the powerapp (when I filter the dashboard the elements in the app filter correspondingly)
is there a way to move the filter the other way around – to filter the App (select an item in the gallery) and make the dashboard filter as well?
Unfortunately the filter context can only flow from Power BI visuals to the Power App; not the other way around.
How did you get Edit Text/Edit Number as your control type in the form ? I can only see View Text in the form on my PowerApp application
There are two kinds of Forms. One is View only. If you use New Screen then choose Form, it starts an Edit form where all fields are in Edit more. Alternatively, you can change a property on each filed to make it editable. Select the form, choose Fields, change Control Type from View Only to another option.
Good article, thank you.
After calling SubmitForm and PowerBIIntegration.Refresh(), the report is refreshed but does not show the updated value, although, the update is reflected in the database, I assume, the Data Set needs to be refreshed. Have you encountered this problem?
Adam,
Is the table storage mode for the table you are working with in Direct Query? If the table storage mode is Import, a page refresh will not reload updated data, this is true if the user manually clicks on Refresh Page or if it is triggered by a Power Apps app.
If the table storage mode is in Direct Query, look and see if the data is actually being updated in the back end SQL table.
Hope this helps.
Shabnam
This is a game changer and now for some dumb questions. If I update the data will the new fields be connected. For example let’s say I bring in work orders from SAP. I then want to create a column with comments. The comments are edited. A day later the report is refreshed. Will the comments for remaining items still be linked and what would happen if an item was there but the work order it was attached to was gone. Would it go away or cause an error?
Hello. I have not worked with SAP but I think this is a data modeling and data handling question. If you are working with more than one table, then you need to have them relate to each other using foreign key/primary key relationships. Here are some links that might help:
https://docs.microsoft.com/en-us/learn/modules/intro-model-driven-apps-common-data-service/1-intro-common-data-service
https://www.youtube.com/watch?v=rkPVrrA-qFQ
As far as what happens to a comment when a work order deleted: This one is a data handling issue. When you delete a work order you should also delete any associated rows from the comments table. Hope this helps.
Hello, I’m not clear on how this works with the On-premise data gateway. If a Power BI data set is refreshed using the data gateway how do the rights to refresh the data set get determined/passed along. We can have a data connection that only a couple of people have refresh rights on but the data sets/reports support are used by 100s of people. Does the PowerBIIntegration refresh override the refresh rights specified on the On-Premise Data Gateway? I assume I’m just being dense and I’m missing something.
Hi, I have an excel stored on OneDrive. I have published the report to Power BI services and creating the PowerApp. When I create the second screen for editing the records and use the formula for Editform ‘Items: Gallery1.selected’. I get an error. Could you please help me to understand the issue. The columns in the table are , , , , .
Hello, The Excel file has to be in a certain format. The area where you want to work with must be marked as a table in Excel. Try the example file that Microsoft provides and see if you can get that one to work, then see what is different between your file and the sample. Hope this helps.