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

In process and still a draft…will remove this line when finished!

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:

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:

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

  1. Create an Application Insights resource

  1. Name your resource instance. If you don’t already have a resource group you can create one.

  1. Create the resource Instance

  1. Copy the instrumentation Key

3. Create a new Power Apps application

4. Set the Instrumentation key

4. Navigate to Components

  1. Create a new component

  1. Resize the component screen

  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

  1. Navigate back to Screens

  1. Navigate to Custom and insert our component SendASmile

  1. Go to file Save and Save your application.

  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

  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.

  1. Open Power BI Desktop. Select Get Data > Blank Query > Connect

  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.

  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.

  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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s