Use Microsoft Flow to archive PDF’s of your Paginated Reports in Power BI

With the recent announcement around E-Mail Subscription support for Paginated Reports in Power BI, you can now have full PDF’s of those reports sent to your inbox on a regular basis. This has been an ask for quite some time in Power BI, but many users have also been looking for the ability to subscribe and have these files delivered a specific location as well, like a OneDrive for Business folder. While we don’t have native functionality for that yet in Power BI, you can use Microsoft Flow to achieve this by taking the e-mail attachment from your inbox and moving it.  Here’s a step by step way to do just that.

First, go to https://flow.microsoft.com/ and do a search for “OneDrive”

The first result returned (for me, anyways) is “Save Office 365 email attachments to OneDrive for Business”

image

Select that, and you’ll see the following recipe –

image

It’ll confirm you’ve provided your credentials for both Office 365 Outlook and OneDrive for Business

image

At this point, you can simply hit “Create Flow” and be done if you wanted to.  However, if you do so, all attachments sent to your Office 365 inbox will be saved in a folder called “Email attachments from Flow”.  Instead, you might not want EVERY attachment in your inbox to go into this folder, but instead just the ones from your Power BI subscriptions, or maybe just a few specific subscriptions.  If that’s the case, we’ll need to make a couple quick changes.  Hit the “Edit” button at the top of the screen

image

The recipe will look like this right now

image

Click on the “Show Advanced Options” under new email.  You’ll see a number of new options you can set to narrow the criteria under which this Flow will run.

image

I’m going to set one where the Subject Filter is based on my e-mail subscription subject name

image

Now it’ll only be done for that particular subscription.  However, I’d like it to add the date to the name of the file so I can easily keep track of which PDF file is for which date.  To do that, I’m going to edit this item

image

by adding two new steps and modifying the “Create file” to append the date to the attachment name.  Add two “Compose” steps – in the first, add the attachment name.  In the second, add the following expression  –

concat(utcnow(‘yyyy-MM-dd’),’_’,outputs(‘Compose’))

Finally, change the “Create file” name to the Output of Compose 2.  This will change the file name to a combination of the date and the attachment name.   Once you’re done, your steps in the “Apply to each attachment” item should look like this –

image

And your entire Flow like this –

imageimage

To make sure it works, let’s test it out.  I’ve sent myself a sample e-mail

image

So I’ll run a Test clicking the “Test Icon” in the upper right-hand corner

image

And I’ll use the data from Office 365 Outlook, since I already have the mail in my inbox

image

The test runs, and says it has been successfulimage

Checking my OneDrive folder, I see that sure enough the attachment is there with the proper date format appended.

image

That’s all you need to do.  Just hit save, and it’ll automatically run against your inbox on an ongoing basis without any work needed on your part.

Microsoft Flow, in combination with Power BI Paginated Reports, provides a powerful way to save report snapshots or, with several additional file types soon to be available for your paginated reports subscriptions, data extracts, in a central location for you to easily archive and share.

Thanks for reading!