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.

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.
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.

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.

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. Follow @CRMChartGuy
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
Hi Thomas. Have not had the opportunity to try it on-premise myself, but the documentation Trond has provided indicates that on-premise is included.
I tried it, it works ! (that’s actually pretty incredible, and makes me hate Microsoft for not delivering this possibility “out of the box”)
Thanks to you for the information, and to Trond for the actual solution 🙂
By the way, i’m running D365 on premise, v8.2.1.176.
That’s great info. Thanks for sharing.
Hi,
It seems to work for me, where did you get this error ?
(i keep the adress https://my.crm.com//WebResources/his_/powerbi/admin.html but then i added wildcard for the addresses in relation to a dedicated report)
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
Hi JJ
I have not run into that issue (yet). Hopefully Thomas’ response above might be of some assistance.
Seems they have changed how this is handled in Azure. I have no trouble using the base url only with no wildcards (https://myinstance.crm4.dynamics.com) on my “old” environment. Tried with a new environment and there I get the Wildcard error.
To fix it go to the manifest editor (as described in steps 16-18 on http://crm-powerbi-viewer.heiigjen.com/pages/azure-ad.html) and set path matching true:
“oauth2AllowUrlPathMatching”: true,
Then reply url https://myinstance.crm4.dynamics.com/* should work as expected.
Trond,
Thank you for the reply, I had the oauth2AllowUrlPathMatching setting set however was not working on my instance.
This is now working as expected and the above manifest change does now allow running the PBI reports as expected.
Happy days!
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!
Really ? Strange, I had no problem at all doing that, here is a screenshot:

Rgds
See comment above. I have also added this new requirement to step 17 on http://crm-powerbi-viewer.heiigjen.com/pages/azure-ad.html.
Thanks Ulrik!
Does this solution work with Power BI dashboards or tiles instead of reports?
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.
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
Hi All, thanks for all the help. JJ, Jennnifer, Trond… I have it working now. Thanks again!
[…] to Dynamics 365 Customer Engagement dashboards and forms with contextual data filters. See also this post by CRM Chart […]
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
Hi Naidera, did you manage to fix this? I’m having the same issue!
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 🙂
Thank you Ulrik! It’s much clearer now. I didn’t know that Power BI Embedded was meant for external users, but that makes sense
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.
Hi Nabil. You can find a sample on filtering at http://crm-powerbi-viewer.heiigjen.com/pages/advanced-config.html
Also appreciate if you (and everyone) in the future could raise questions at https://github.com/taarskog/crm-powerbi-viewer/issues. This way we have a common place to search and track questions and answers.
Hope this helps
Hi Nabil, now are you able to filter user or account id in your powerbi report embedded in CRM?
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
Hi Sergio. I agree it is a great solution. Your question is a little too detailed for me, but you can raise it with Trond directly on his GitHub here https://github.com/taarskog/crm-powerbi-viewer/issues
Hi Ulrick, have you embedded a PowerBi report filtered by account id in your CRM?
Sergio, great question. In order to reference the web resource use the url generated when you created the jscript resource. for example
custom_scripts: [“https://yourorg.crm.dynamics.com//WebResources/new_accountfilter.js”]
Find it in the general tab of the web resource
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.
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.
Disregard this last post. I was using individual tiles which is why events like pageChanged were not options to me. As soon as I embed an entire report Boom filters work like a charm. Again thanks Ulrik this was much appreciated
Hi Alex. With release v1.1 you can now show single visuals from a report. Giving the same effect as a tile with the added bonus of supporting filters – you can find the required configuration at the bottom of this page: http://crm-powerbi-viewer.heiigjen.com/pages/add-view-to-dashboard.html (see section named ‘single visual’).
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.
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!
[…] 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/ […]
hey, I’m getting an error which says the reply url is request is not matching with the one configured. I have posted my question on forum as well https://community.dynamics.com/365/f/761/t/311048
can somebody help please?
I’d recommend checking some of the comments over on this Trond’s Power BI Viewer site. I know it has been discussed there in the past. But also check out this blog post for a new way achieving this https://crmchartguy.com/2019/02/18/embed-power-bi-visuals-in-dynamics-365-with-secure-embed/
Hey Ulrik, thanks for replying. I tried all of them but still getting the error. I couldn’t see the reply URL that was being sent over with request. I’m new to this and don’t really know much. Do you mind telling me how can I see the this reply url? I checked it in config on Azure portal but that one isn’t working.
The URL you mentioned, that feature is only available for paid version. Currently, I’m using the free version.
Thanks
hey Ulrik, got it fixed by * at the end of base URL. Thanks for pointing me in the right direction.
Great. I’ll say though, that if you are on the free version of Power BI, then no one but you can see the visuals.
@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.
I can’t answer that one. I think your best bet is to try on Power BI Viewer’s GitHub https://github.com/taarskog/crm-powerbi-viewer
[…] Contextual Power BI Reports on Dynamics 365 forms […]
Ulrik,
can you explain where the value in the for the In operator and where is that value coming from?
operator: “In”,
values: [accId]
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