Contextual Power BI Reports on Dynamics 365 forms

I have mentioned on a few occasions that Power BI does not allow you to iframe its components. This means you cannot just add an iframe of a Power BI report inside Dynamics 365 on a customer form, for example.

While Power BI does not allow this directly, the statement does come with an asterisk.

You can, but you will have to create an app in Azure, give it proper privileges and then develop some plugins in Dynamics 365 that handles the authentication. Not an easy task and probably out of reach for non-developers.

So I got really excited when I recently found a solution called “Power BI Viewer” that does exactly that. The solution has been made by Trond Aarskog, who has been generous enough to make it available on his website. http://crm-powerbi-viewer.heiigjen.com/

Trond has provided easy to follow steps on how to create the app in Azure and make the initial configurations in Dynamics 365.

Once those initial steps are completed, you can add Power BI reports and Power BI dashboards on Dynamics 365 dashboards. You could already do that, so that by itself isn’t amazing. The amazing part is that you can add custom functions to Trond’s code that allow you to add filters contextually of what you are viewing in Dynamics 365. For example, that means on your account form, you can now add a Power BI report and filter it dynamically to only include data for the given account and include images from Dynamics 365 too.

Power BI in Dynamics 365 form
Power BI report in Dynamics 365 filtered for the current account.

BOOM!!!

Trond also has the details on his site on how to setup the filtering.

Since you can pass the ID of the record you are now able to do stuff like:

  • Filter a report according to the given record
  • Use the Power BI maps with data added
  • Create a common table for both activities and notes and display it on the report
    • Use the data model to include records from any children or associated records
  • Pass guid of the active user and filter a Power BI report accordingly (NOT possible in Power BI itself)
  • Use custom network visualizations in Power BI to show relationships
  • Power BI reports are added as web resources which means they can be added to system dashboards

In addition, Trond’s solution also lets you embed Power BI reports in Dynamics 365 On-Premise!

Couple of lessons I learned while playing with Trond’s solution:

Notes On Setup

(This section probably won’t make sense until you’ve looked through Trond’s guides) While I definitely encourage you to read through Trond’s guide for the setup first, here are some of my notes that might be helpful.

When adding the Application ID from Azure to the configuration file, the ID needs to be in quotation marks.

When filtering reports according to a record ID, note that Dynamics 365 passes the guid inside a pair of { }. Power BI exports the guid without {}. Make sure your web resource removes the {} from the guid before applying the filter.

Here’s the script I used to filter on the account ID. It is based off the sample available on the Power BI Viewer website.

Of course, the table and column name here will have to match what you have in your Power BI data model. And of course, in the properties for the web resource on the form, check the box for passing the record ID.

NOTE: Trond is planning to update this part of the solution once the new CCF SDK becomes available and make it much easier for everyone to use. YEAH!!

Entity Images

You can include the entity images in your Power BI reports and they will display when shown inside Dynamics 365. I.e. pictures of users, contacts, etc.

However, they will not display in the Power BI Desktop Client or when using the powerbi.com by itself. The area where the image is supposed to be just shows up blank.

You can see the Dynamics 365 images on powerbi.com, if you have a tab with Dynamics 365 open at the same time. So basically, when viewing the images from Dynamics 365 in Power BI, your browser needs to be authenticated against Dynamics 365 at the same time.

Report Page Size

When adding the Power BI Viewer to a form, you can specify the amount of columns and rows the webresource should use. Power BI will display the entire report page inside the area you defined. This means any white area on the report page surrounding the visualizations will be displayed as well. You can effectively change the report page size to match the size of the area you want to show the report in. That will help you size the charts better.

pagesizesettingsmatchcanvas

The view mode also affects how the report is displayed in Dynamics 365. Use Actual Size to force a specific measurement. This will add scrollbars on the report if the window isn’t large enough. Fit to Page and Fit to Width will change the size of the report with the window size. It seems to be best to use Fit to Page when saving the report, but it is helpful to use Actual Size while modifying it.

Set view mode to actual size to get a better idea of how it might look in Dynamics 365. Set to Fit to Page when saving.

Disable Navigation and Filtering When Displaying On Forms

Make sure you set the ShowFilterPane and ShowNavPane in the web resource properties to false. That will give the report more space on the form.

Setting the ShowNavPane and ShowFilterPane to false will give the report more space and not take up screen real estate as shown above.

Maps

While you can use the regular Power BI maps, the ESRI ArcGIS maps are not allowed when embedded in this manner. This intentional limitation also applies to the Power BI Embedded service in Azure.

The Catch

There’s gotta be catch right? The reports do load a little slower than the rest of the form, but nothing that is not manageable. Main catch is that you will need a Power BI Pro license (or Power BI Premium) in order to share the reports. You will also need to remember to share your Power BI reports with all the Dynamics 365 users.

Also, your reports will only be as up to date as Power BI. Depending on your refresh rate, that could be up to an hour, or longer if outside business hours. This is of course an area where the Data Export Service could be used successfully to get closer to live data.

Hope you all find Trond’s solution as helpful as I have. I definitely think the solution fulfills a very significant gap in how you can use Dynamics 365 and Power BI together. If you have listened to any of the CRM Audio Power BI episodes, you will occasionally have heard Scott Sewell and I talk about different workarounds to get this kind of contextual reporting. Those workarounds always included some kind of link or button that would take the user to the report, rather than just displaying it inside the form. This is now possible. I am definitely looking forward to working more with this solution and will of course share tips and tricks that I find useful, so don’t forget to sign up for my newsletter or follow me on Twitter.  

53 thoughts on “Contextual Power BI Reports on Dynamics 365 forms

  1. Hi,
    I see there’s a mention in the configuration that we must change something if we use CRM on premise… but I also see that we need Azure Active directory and connect the APP to the CRM online service.

    Is it a tool we can use to allow powerBI on a OnPremise CRM instance, or is it a false hope ? 😉

    Rgds

  2. Ulrick,

    A great and timely post, thank you.

    I noted when I was trying this that I got an error that “Wildcard based reply uri match is not supported.”
    Have you come across this as well (and possibly found a solution)?

    Regards

  3. Thomas and Ulrik,

    Thank you for the prompt responses!
    I suspect the issue is in the AD Application configuration … to be confirmed.

    The error appeared for me first in the admin page (until I changed the reply address to include that page, similar to your URL above, Thomas, but I also needed the ?pagemode=iframe on the end of the admin page reply URL for it to work).

    However now I’ve found that the full length of the reply URL for the dedicated report address is too long for the Azure AD application’s reply URL storage, so without wildcard support, I am not yet able to add any report elements to Dynamics pages.

    Stay tuned!

    • Henry, it works with all of them (reports, dashboards and tiles) – you choose what you want to embed and you can embed any of them into both CRM dashboards and forms. You can also embed more than one onto the same dashboard/form.

  4. Hi, first of all this looks impressive. Wanted to try it out in my environment but I get an error when opening the solution to check on the id’s of the tiles. The error reads like:

    ‘https://xxxxx.crm4.dynamics.com//WebResources/his_/powerbi/admin.html’ does not match the reply addresses configured for the application: ‘df2841aa-4a50-42db-8fc0-16b113370721’. More details: not specified

    Any idea what might be causing this? I followed the instructions very thoroughly

    Thanks in advance

    • Hi Sergio – I was having same issue. I just had to update the Manifest per Trond’s updated step:

      1. set path matching true: “oauth2AllowUrlPathMatching”: true,

      Then, even though I did enter my URL with the wild card, my reply URL did not have it listed, so I:

      2. Clicked on Settings >Reply URLs and added asterick to the URL there
      a. Old = https://company.crm.dynamics/
      b. Updated to = https://company.crm.dynamics/*

      All is good!!

      Thank you for all the work and guidance Trond! This is brilliant!

      -Jennifer

      • Jennifer – you are bad ass! We have been searching for a solution for a few days, and you just solved it with an *….rock on girl!

    • Sergio,

      I would second Jennifer’s comments, these are the key steps. If that does not work …

      I would then suggest creating a second AD application using the instructions (and changing the ID that Dynamics uses), I had an issue with the AD application not using the oauth2AllowUrlPathMatching setting correctly (even though it was correct in the manifest), and it only recently got fixed.

      Regards

  5. Hi. Is it known why no configuration page interface of the Power Bi Viewer solution appears? It just shows me text and no connection to available reports and dashboards as graphical interface. And even if I can´t see this connection is there any other way to get the configuration values of a vizualization to embedding them in a dashboard?

    Regards

  6. In terms of licensing, can we consider using the Azure service “Power BI Embedded” in order to avoid having to license users and share reports in PowerBI.com? Would that solution cover that scenario?
    Another option is to use Power BI Premium capacity to store the reports / dashboards and share the worksplace with users who do not have a Power BI Pro license.

    • You can use “Power BI Embedded” technically, but you will be double dipped on licenses since you still need to pay for the Power BI Pro license, because the users are your employees. “Power BI Embedded” is intended for external display of reports.
      Yes, your suggestion of using Power BI Premium would remove the requirement of Pro licenses for users who do not create reports.
      And most importantly, I am not certified in giving advice on licenses, so this is simply my best understanding of the subject 🙂

  7. Hi
    great solution but i’m not able to filter user accountid !
    when debugin , i see that the Dyn call my javascript function but no data is filtered from the report.
    does some one tried to test to filtre data from a Bpi report ?
    thx for your help.

  8. Hi, this is a great solution for Dynamics/PowerBI users!

    I followed the Trond’s guide and I see my Power BI report in Dynamics 365 dashboards and forms 🙂

    I have some issues about data filtering: following your guide I created the web resource for Account filtering (new_accountfilter.js); I adding this in his_/powerbi/scripts/config.js:

    // Array of custom scripts to load. Functions in these scripts can be referenced for report filtering etc.
    custom_scripts: [“new_accountfilter.js?ver=1]

    is this correct?

    After in the form I modified the web resource properties adding &customFn=Samples.Filters.filterOnAccount
    and selected the option to pass the record Id

    Thanks
    Sergio

  9. Hi, am I correect when i say that you need a full PBI license to view the PBI content in CRM via this “Contextual Power BI Reports on Dynamics 365 forms”?

    What I can see when trying this is that i need a full license but I hope that I’m wrong in this question. And I dont want to use the “Share the whole report”-approach via an Iframe inside CRM.

    • Hi Håkan. You generally always need a Power BI Pro license when sharing the reports. Both the sharer and the viewers. The exception is if you have Power BI Premium and you won’t need the Pro license for the viewers.

  10. Hey Ulrik, great post extremely helpful. however one thing, I have my tiles on the account page no problem, but when trying to filter using the exact sample you have (filled in with my report properties page name etc), nothings changing. It actually didn’t render until I used dev tools and found out pageChanged needed to be changed to something else, so i used tileClicked event. Now that got the tiles loaded but still no filtering, I now see LoginRequestCorrelationId is not present in Access-Control-Allow-Headers list “the server understood the request, but is refusing to fulfill it” showing as an error?? Is this an issue with using Dynamics 365 Version 9.0? any work around to this?? Any help to this would be MUCH appreciated, thanks.

  11. Would this embedded Report follow RLS if we have that set up ?
    In such a case, filtering can be handled at Security roles level in Power BI.

    An alternative could be using a Power App embedded as an Iframe

    • Yes, the report would adhere to RLS, but RLS would only mimic D365 security to the extent that you implement the logic in your data model.
      A Power App could possible do this too, but at this point I’ll wait and see what the built-in functionality brings that was listed as part of the Oct18 release. Although, as of writing, I don’t think has been released yet.

  12. Hi Ulrik, thanks for your great posts and helping us a lot! I followed the steps in this post and embedded a Power BI report page in an account form in Dynamics 365 Sales v9.1 online (free trial) by passing an account id (GUID). I was able to pass a parameter and was able to display the Power BI charts filtered by the account id. Cool!

    However, the filtered visuals are not displayed when I open an account form. It is loaded and displayed but I need to click on a different page (tab) of the Power BI report embedded in the account form and come back to the page that I passed the account id parameter then the page is filtered and nicely displayed…any ideas why? Does it have anything to do with a JavaScript model change in v9.0 later? Your help would be very much appreciated!

    P.S. I was in a Microsoft training in Houston last month. Gus (MVP) was a trainer and he showed us your M Query Builder YouTube video. That was awesome. I was looking for a tool to simply apply views in D365 CE to Power BI!

    • Hi UG. Yeah, the new UI makes it a little tricky and inconsistent. According to the release notes, this process is supposed to become an out of the box feature in the near future, so we are on the threshold where it may be worth waiting, rather than trying implement this solution. There’s no right answer on that one though. It all depends on when you need it.

      • Hi Ulrik, thank you for your response. I agree that the current UI is not consistent, and I think not stable either. We see changes and new things added to D365 consistently these days, so it would be difficult to catch up and keep updating…hopefully the solution will be available as an out of the box feature soon!

  13. @Ulrik, yeah, you are right. Only I can see it and rest cant. Also, I was trying to implement advanced filtering. The scenario is, I have a client form and I want to show the graph for only that user. I followed everything you mentioned and the documentation ( http://crm-powerbi-viewer.heiigjen.com/pages/advanced-config.html ) by Trond but it is not working. I’m getting 404 for “samples/filters.js”, eventhandlers.js”.

    https://xyz.crm.dynamics.com/%7B636863832130002057%7D/WebResources/his_/powerbi/samples/filters.js?ver=1

    https://xyz.crm.dynamics.com/%7B636863832130002057%7D/WebResources/prefix_/scripts/eventhandlers.js?ver=1

    I’m not getting what I’m missing out on? Could you please help me in solving this issue? Thanks for your prompt replies.

  14. Hi Ulrik

    Excellent article, thank you, I’m looking forward to using it.

    The problem I have though is to replicate the existing ‘run report’ function from within a form with a Power BI report rather than SSRS – so many of my reports have to be run that way and I’d really like to start using Power BI properly. Do you know of a solution to that issue please?

    Cheers
    Jules

Leave a reply to Ulrik (CRM Chart Guy) Cancel reply