“Powerful alone. Better together”. If you believe in this, then this blog will help you to understand how integrating two different robust tools (Power BI and Power Apps) enables you to quickly deliver something amazing. Both Power BI and Power Apps are part of the Microsoft Power Platform.

Power BI is a business analytics tool with exceptional visualization characteristics. Using PowerApps visual in Power BI allows you to enable the power of PowerApps into Power BI reports. This visual adds another layer of functionality into the Power BI report.

Scenario

A business uses Power BI for their analytic reporting. The user’s requirement is to investigate and identify the customers with overdue invoices and ability to follow up by sending an email with the details, directly from the Power BI report.

Approach

Our goal is to create a Power BI report and include a PowerApps visual into it. The Power BI report will allow users to do analysis and identify the customers having overdue invoices, and using PowerApps visual we will enable the functionality of sending an email from the Power BI report.

Let’s start by creating a dataset for the Power BI report. For this example, I am using SQLServer as a source with "Adventureworks" sample data. First create a sample “InvoiceData” table and insert data into it for our reporting.

Now create a Power BI report. Open Power BI desktop and use “Get data” to connect with the “InvoiceData” table. Choose data connectivity as Import or DirectQuery based on your data refresh requirement. For more information on storage mode and dataset refresh refer here.

Below is the report created using Power BI desktop. I have left some space in the canvas for the PowerApps visual control (to add later). Publish the report to Power BI service.

To calculate Due over days, create a calculated column using DAX 
Due Over (Days) = DATEDIFF(DueDate,Today(),DAY)

After publishing the report to the Power BI service, switch to report edit mode and insert the PowerApps visual in the report. It will also show instructions on how to get started.

Start by selecting the fields you want to include in the app. As soon as you add the first field, the PowerApps visual will ask you to select “Choose app” or “Create new”. Click on “Create new”. 

An existing app works only if it were previously created from the Power BI service. If you want to use existing app, you may need to make some changes to get the data integration part work properly, PowerBIIntegration is key for data integration between Power BI and PowerApps. 

Clicking "Create new" will take you to the PowerApps studio, where you design the app. The PowerApps connects and triggers data refresh through a function called PowerBIIntegration.

You can now adjust and design the layout of the default gallery. For this example, I have created two screens.

Screen 1- To show order and customer details
Screen 2- To send an email to the selected customer with information

Create the item controls and change the data points for the gallery items. Use the function ThisItem.ColumnName for the current record in a Gallery or form control.  

Next, we will add a second screen for email. Go to the Home tab and click on new screen and choose blank.

Let us add label controls, text controls and a HTMLText for the email body and design our Screen 2. It's important to set the text property to gallery1.selected.columnname to auto populate the values in the Screen 2 based on the Screen 1 selection.

 

Add an email icon on the top right (or wherever you prefer) to use it to send an email on click. Set the "OnSelect" property to this expression:
Office365.SendEmailV2(TextInput1.Text,SubjectTxt.Text, HtmlText1.HtmlText); Notify( "Mail Sent :)",Success)

Give the app a name and save it. Now switch back to your Power BI report. Your PowerApps visual will now show the newly created app in the Power BI report. Save the report. 

Here, in our example the customer details are displayed, you can select any record items in the report, and the data in the app updates. Select any record and click the ">" icon to go to the email screen. 

On clicking the email icon, you will be able to send an email directly from the Power BI report. 

Conclusion

By combining Power BI and Power Apps users can build powerful analytic solutions which enhances analytic visualisation as well as enable users to act right away from the Power BI report.