Using PowerApps and Flows to Refresh PowerBI Dataset
By: Scott Goley
Tags: Power Bi, Data, Refresh

TLDR

Made a microsoft flow to trigger powerbi dataset refresh.

Embedded a powerapp into powerbi report that contains trigger / button for said flow.

Refresh button for powerbi dataset underlying report? Read more to find out!

Use Case

I originally started out looking for ways to cause a powerbi dataset refresh from a report. The standard functionality of powerbi is only to refresh the “view” and not the underlying data. On the powerbi.com service, you are able to do this in the dataset section of the workspace by hitting a specific button.

This report being an import based model, I needed a way to initiate the dataset refresh from the report. After an extensive search, I came across a blog post that referenced the possibility of using powerapps to trigger a flow that refreshes the dataset.

There was some attempt to do this before recorded here: http://dataap.org/blog/2019/02/05/dataset-refresh-in-powerapps-custom-visual/

But I have yet to see any serious writeup of the whole process and its outcomes. That was enough to get started with!

Microsoft Flow

First things first, we need to define a callout which will initiate the refresh.

Here is that earlier referenced blog post: Refresh PowerBI Dataset with Microsoft Flow

Big thank you to Konstantinos for that. After completing your refresh callout, you need to substitute the “trigger” with a powerapps input like so:

I spent a good amount of time trying to parameterize the dataset ID so that the same visual could be embedded in any report and operate on the same flow. Something along the lines of:

But since I have not been successful in making that version work, I focused on implementing an MVP for a single report using hardcoded dataset values.

Powerapps

I’m still learning about what powerapps is (first impressions is a better front end for SSIS not unlike how PowerBI is for SSAS) but that said, it’s approachable enough to build out an mvp in a day.

As a consequence, I went with the absolute simplest version of an app that I could think of — an entire app dedicated to being a single button, “refresh” — not unlike the target functionality on the dataset refresh button earlier referenced.

I created a 300px wide by 100px tall workspace and built up the visual like so:

If you’re interested in reusing this app, please contact me directly.

Making sure that you include the PowerBI Integration as well as the elements and making sure at the very least that your button press action is set with the yourappname.run() function.

Following that, jump back into microsoft flow and you should be able to setup a process with the trigger being your PowerApp and the triggered action being your Flow callout.

After setting up that Flow — if you go back to your PowerApp, you should be able to see that PowerApps picked up the interaction here and whenever you “press” your button, it will now trigger your flow to run.

Powerapps embedded visual

Last steps for testing — you will need to install the PowerApps Embedded Custom Visual into your PowerBI report much like any other custom visual. Pick that up here:

PowerApps Visual on AppSource

Then, you can login to Powerapps through the visual after you add any data field from your model (You are welcome to try and pass the report id parameter as previously mentioned)

PowerApps will give you a choice of the apps which are available to you through your login:

And most likely embed a large version which is scaled to your visual:

So just resize and then start testing to make sure that all the functionality that you built in works as intended! For this example I included a refresh “spinner” plus shading on hover and a few other UX elements.

Alignment

One thing that I would like to note in case you develop any similar solutions or build your own with the custom visual is to pay attention to the alignment issue. There are some super helpful settings within the App Settings below which you will definitely need to tune to the version you are emedding. I had numerous issues before finding the scaling and orientation toggles.

Outcomes