Creating a Send-smile-component for Power Apps using Power BI and Application Insights

Early February we released an exciting new feature that enables you to add telemetry logging to your application using Application Insights.

That blog post can be found here:

https://powerapps.microsoft.com/en-us/blog/log-telemetry-for-your-apps-using-azure-application-insights/

This blog post is a walk through for getting that running specifically for creating a send a smile experience from your Power Apps.

You can also find a video of this walk through here: https://youtu.be/Kv8TOOeyj48

The walk through steps:

  1. Log into your Azure Subscription.While this walk through requires an Azure subscription, that subscription does not have to be in the same directory in your Power Apps tenant
Send-smile-component for Power Apps
  1. Create an Application Insights resource
Send-smile-component for Power Apps
  1. Name your resource instance. If you don’t already have a resource group you can create one.
Send-smile-component for Power Apps
  1. Create the resource Instance
Send-smile-component for Power Apps
  1. Copy the instrumentation Key

3. Create a new Power Apps application

Send-smile-component for Power Apps

4. Set the Instrumentation key

Send-smile-component for Power Apps

4. Navigate to Components

  1. Create a new component
Send-smile-component for Power Apps
  1. Resize the component screen
Send-smile-component for Power Apps
  1. Add a smile and frown Icon to the component.
  1. Select the frown icons and add the following code:Trace(“SendASmile”, TraceSeverity.Information,{ChucksappName : “Blog App”, Satvalue: “-1“, AppUser: User().FullName })
  1. Select the smiley face and insert the following code in on the OnSelect event

Trace(“SendASmile”, TraceSeverity.Information,{ChucksappName : “Blog App”, Satvalue: “1“, AppUser: User().FullName })

  1. Rename the component. You can do this by double clicking or right clicking on the component name > Rename
Send-smile-component for Power Apps
  1. Navigate back to Screens
  1. Navigate to Custom and insert our component SendASmile
Send-smile-component for Power Apps
  1. Go to file Save and Save your application.
Send-smile-component for Power Apps
  1. To find the play URL. Navigate to File > Settings and select Edit App Name
  1. Navigate to the Web Link. This is required as the telemetry is only collected in “play” mode rather than design mode.
  1. Run the application and click on your icons a couple of times
Send-smile-component for Power Apps
  1. Navigate back tot the Azure Portal and Application Insights.

In Application Insights choose the application you create

  1. In about 5 minutes you should be able to see your telemetry start coming through.

Exporting your Application Insights resource data to Power BI

Now that you have your Power Apps application connected to Application Insights you can configure Power BI to automatically import log data from Azure Monitor to take advantage of these additional visualizations.

  1. In your query window remove the limit line so the entire query is simply “traces”. Select Export > Export to Power BI. This will export the M Query that you can use in Power BI desktop.
Send-smile-component for Power Apps
  1. Open Power BI Desktop. Select Get Data > Blank Query > Connect
Send-smile-component for Power Apps
  1. In the Power Query Editor, select the Advanced Editor option. In the advanced editor erase the default query and paste in the query downloaded from the Export step above.
  1. Here is an image of this in a completed state. Select “Done”
  1. Transform the customDimensions column to JSON
  1. Select the customDeminsions column and select the columns you are interested. Note: you will almost certainly need to click “Load More” to see all the values.
  1. Select the customDeminsions column and select the columns you are intereste in.
Send-smile-component for Power Apps
  1. Remove Errors. As we expanded a column that doesn’t have all the values there will be errors in the dataset. If you do not do this you will get the error:

Failed to save modifications to the server. Error returned: ‘OLE DB or ODBC error: [Expression.Error] The parameter is expected to be of type Text.Type or Binary.Type.. ‘

  1. Change the data type of our SatValuue to whole number. Note: In later releases you will be able to pass in numbers from Power Apps and this step won’t be needed.
  1. Select Close and Apply. Note if you get errors from other columns you can either ignore them remove them by repeating the remove error step as shown above for the other columns.
Send-smile-component for Power Apps
  1. You can now work with this dataset as any other Power BI Dataset….In this case a card is displaying the average Satvalue. Note since this dynamically retrieving data from Application Insights you would likely want to use a DataFlow to persist the data over time.
Send-smile-component for Power Apps

Reference:

Sterlings, C. (2020). Creating a send-smile-component for Power Apps using Power BI and Application Insights. Available at: [Accessed: 24th March 2020-.

Find more great Power Platform content here.

Share this on...

Rate this Post:

Share: