Embed Power BI Visuals in Dynamics 365 – with Secure Embed

Power BI recently started supported embedding Power BI visuals securely out-of-the-box. That means we can now show Power BI reports inside Dynamics 365, without having to deal with authentication.

And with minimal use of code, we can filter the visual to the record that it is being displayed on. Like this.

Power BI on Dynamics 365 form

I have previously written about embedding Power BI visuals on forms in Dynamics 365. Until recently that required code to handle the authentication, or use of Trond’s “Power BI Viewer” tool to handle it for you. That’s all described in this blog post. https://crmchartguy.com/2018/02/11/contextual-power-bi-reports-on-dynamics-365-forms/

The new embed feature in Power BI handles the authentication for you and is easy to use. On the Power BI website, navigate to the report you want to embed in Dynamics 365, click on File, and select Embed.

secure embed in Power BI button

This will give you a link referring to the specific report.

secure embed link from Power BI

Try it out and paste the link in a browser and you will see the whole report without the Power BI menus etc.

In our scenario though, we want to filter the report to a given customer and then show it on the Account form.

To filter the report, we can use the standard URL filter parameters. I’ve discussed those in more detail here. https://crmchartguy.com/2017/03/30/record-specific-power-bi-reports-in-dynamics-365-only-one-click-away/

In short, we need to add ?filter=Table/Column eq ‘GUID’ to the end of the link we got from the Secure Embed feature.

An example of filtering to the account record would be:

?filter=Account/accountid eq ‘329874328fsh9843298743298’

This example assumes the table is called “Account” and the field with the GUID is “accountid”.

All URL filter parameters, in case you need more advanced filters are available here. https://docs.microsoft.com/en-us/power-bi/service-url-filters

Now I just need a web resource that takes the embed link from Power BI and tags on the filter parameters including the GUID of the current record.

As I am no developer, I found this old web resource which did something very similar. I am sure it can be optimized by a real developer. (In case you are curios, the web resource is from the old Customer Insights solution. I believe Microsoft has taken the material down, so I can’t provide a link to the original.)


<body style="overflow-wrap: break-word;">
        function ready(fn) {
            if (document.readyState != 'loading') {
            } else if (document.addEventListener) {
                document.addEventListener('DOMContentLoaded', fn);
            } else {
                document.attachEvent('onreadystatechange', function () {
                    if (document.readyState != 'loading')

        ready(function () {
            var filterValue =  window.parent.Xrm.Page.data.entity.getId();
            filterValue = filterValue.replace('{', '%27').replace('}', '%27');
            var loc = "INSERT YOUR POWER BI EMBED URL HERE&filter=Accounts/accountid eq ";
            loc = loc.concat(filterValue);
            document.getElementById('aci').src = loc;



     id="aci" src="" width="700" height="380">



Disclaimer: Code sample provided for fun and testing purposes only.

In Dynamics 365, create a new web resource of type HTML in the solution editor.

add web resource to Dynamics 365 for adding Power BI report

Copy the above web resource code into it with two important modifications.

copy and paste web resource into source tab

  • Insert your URL from Power BI
  • Modify width and height to match the intended area on the form

Go to the Account form to add the web resource we just created. Make sure you give the component enough space on the form.

Add iframe and webresource to account form in Dynamics 365 to show Power BI report.

Once added, we can publish and see the Power BI report embedded, filtered to the current account,  and authenticated directly via Power BI.

Power BI on Dynamics 365 form

When using Trond’s Power BI Viewer, we had some options to hide the filter pane and navigation tabs. Those options do not seem to be working here (based on my limited testing).

Note that we in the October 2018 release notes were promised an out of the box feature that would handle this process automatically. Link here. https://docs.microsoft.com/en-us/business-applications-release-notes/october18/powerapps/power-bi-embedding-available-in-common-data-service-entity-forms

It seems that the Secure Embed feature has been a prerequisite to make this work, but it is of course still anyone’s guess when the built-in feature in Dynamics 365 will be released.

This is one of the features from the October 2018 release that I am the most excited about. And yes, I do realize I am writing this in February 2019.

For now, I do consider the above a nice option for demos and proof of concepts. If used in a Production environment, I would consider this a temporary measure until the baked in feature is available.

As with any Power BI report, the data does not adhere to the Dynamics 365 security model, so be attentive to what is being shared. There is also an assumption that the users in Dynamics 365 have the Power BI report shared with them and that they have a Power BI pro license.

Here’s the link to the Power BI blog introducing the feature https://powerbi.microsoft.com/en-us/blog/easily-embed-secure-power-bi-reports-in-your-internal-portals-or-websites/

Enjoy. As always, please sign up for my newsletter or follow me on Twitter 

16 thoughts on “Embed Power BI Visuals in Dynamics 365 – with Secure Embed

  1. add this in power bi link if you want to remove filter and navigation


  2. Hi Ulrik,

    Since this is done via a web-resource is it possible to deploy this on Dynamics crm 2016 On-Prem?

    We have a D365 on-prem instance we use for testing feature before we up-grade but it is not configured with IFD.

  3. Did you modifythe html? I can see there is a closing before the tag. Did you open it after the first script function?

  4. Hi, thanks for the great article. I’m trying something similar and was hoping you could help. I’m trying to embed a Power BI report in Dynamics CRM Customer Portal. The customer portal has external users (They’re as contacts in CRM). So they login to CRM using a username and password provided by the customer portal. We added the external user’s email address (like gmail) to our Azure Active Directory as a guest user and granted them access to the Power BI report. Once we share the report with that user, they are able to access it through Power BI website, but the problem is when they try to view the embedded report they are presented with a button to login, and when they do we get an error saying they can’t be authenticated.

    Any idea how to embed Power BI report in customer portal for external users?

    Thank you!

  5. Ulrik thank you for all your amazing content. Videos, blogs, tips, everything.

    I am going to piggy-back off of @Hasan’s comment of trying to get filtered charts to show for Dynamics Portals external users.

    If I wanted to post these charts filtered by “Account” inside of Dynamics 365 Portal. Would the same concept work for “Contacts” and “contactid” inside of Dynamics?

    I know how to filter by “Account” and then by “Contacts” to show list, and charts.

    But in your example here how would you code this for “Contacts” to filter by contacts?

    Thank you again for all of your content.

  6. Hello, Do you know if it is necessary to have a Power BI pro license to view Power BI reports integrated into a CRM form?

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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