Recently I was asked by a client to look into the possibility of using Power BI Dashboards/Reports and displaying them inside their CRM Online instance. One of the priorities for the investigation was to ensure that the dashboards/reports could be filtered for the current user. For my test I want to be able to build a dashboard that shows the CRM activities for the logged in user.
Power BI licensing looks very reasonable. No cost to author reports and publish online, and $9.99 (approx £7.50) for the Pro version which gives the ability to be able share reports and schedule data refreshes. Also, a quite lengthy 60 day trial is available which is plenty of time to see if it’s right for you. After a bit of reading it seems that Power BI can be set to suck in data from a number of data sources, store it internally, and then build very nice looking charts from the data. The data can be set to refresh at regular intervals, though the minimal refresh period is 1 hour, and this scheduled data refresh requires a Pro license.
Data preparation in CRM
To enable me to test the reports/dashboards I’ll be using the CRM Activity entity. There are a few dozen records in my test CRM instance, and I am the owner of one of the activity records.
Power BI Desktop
Using my MSDN account I created an Azure Virtual Machine running Windows 2012R2 and installed the Power BI Desktop. It’s free to install and use (the installer is 143MB).
Adding Data to Power BI
Clicking on the Get Data button brings up a dialog with a list of many available data source types. Entering 365 into the search box filters the list allowing the selection of ‘Dynamics 365 (online)‘.
The next dialog prompts for the Web API URL for the CRM instance:
The Web API URL for your instance of CRM can be found by navigating to Settings\Customizations, clicking on Developer Resources, and copying the value out of Service Root URL. Selecting the value with your mouse and then using Ctrl+C will copy the value.
Next is a prompt for my CRM login credentials. Having entered the credentials a list of entities that are in the CRM instance is displayed. I selected systemusers and activitypointers – filtering the list using the search box makes it easier to find an entity:
Filtering Data by User
The data can be filtered to only show data for the current user by using Row Level Security (RLS). RLS is basically how you can configure the data to be filtered by criteria which is configured per role. I will simply be adding a role to filter the systemusers table for the logged in user, and as the activitypointer table is joined to this table, it will be filtered also.
The first step is to make a one-to-many join between the two tables. This is achieved by clicking on the relationships tab to go to the mapping screen.
From here the two tables are visible, and can be resized to view more of the columns. To create the link drag the systemsusers ownerid column to the activitypointers _ownerid_value column:
There should now be a line linking the two tables with a 1 on the systemusers side and a star on the activitypointers side. Double clicking the join allows the properties to be viewed – it should be:
The next step is to add the filter. Click back to the Home tab and then the Manage Roles button:
This is the filter that should be added:
We can now add the data to the main view area. For our test a simple grid of data will be sufficient. On the list of Visualizations click the Table icon:
This inserts a table onto the main view area and columns from the far right table can now be dragged onto it. Formatting the table is done by selecting the table, then the ‘Paint’ icon and changing the values.
This is how mine looks:
It’s very important to test what we’ve done as we don’t want users seeing other users data. Click on the ‘View as Roles’ button:
Then enter the following selections, using your email:
The data in the table should now be filtered to display just your data:
The next step is to Save and Publish the Dashboard to Power BI Online. This is done by clicking File\Save (mine is called CRMUserActivities) then File\Publish and then Publish to Power BI.
Next, go to the Power BI application website. The next step is critical also, as we’re going to configure which users the Filtering applies to. Expand ‘My Workspace‘ and under DataSets there will be your dataset. Click on it, then click the ellipsis, and the menu option Security:
Now, all the users should be added to the Row-Level Security. This can be a bit tedious but I don’t think there is any way around this:
Convert Report to a Dashboard
To convert the report to a dashboard that is viewable on CRM the first action is to open the report and click on ‘Pin Live Page’
A dialog is displayed and ‘New dashboard‘ can be selected and the name of the dashboard entered:
By default Power BI displays Report page numbers which can make the dashboard look a bit untidy. Removing the page numbers is not very intuitive, and it took me a while to figure out how to remove them. Firstly click on the new dashboard that has been created under the My Workspaces tab:
The next step is a bit tricky. Move your mouse over the dashboard and an ellipsis should appear to the top right. Click on this ellipsis:
This brings up another menu, click on the ‘Pencil’ icon:
Finally, we are on the correct the window. Untick ‘Display title and subtitle‘ and then click Apply.
Note: There is also an option on this dialog to ‘Display last refresh time’. This is the date/time the Dashboard was refreshed by Power BI – an item you may want to show to yours users.
Add the Dashboard to CRM
We’re nearly there.. To enabled Power BI dashboards in CRM there’s a setting under Settings\Administration and then System Settings. In the Reporting tab there’s an option to enable Power BI Dashboards – set this to Yes:
In CRM, go to the Dashboards screen, and click on the arrow to the right of the New button, and select Power BI Dashboard:
And finally you can select your Power BI Dashboard
I also added a pie chart and a total count to my dashboard.
An added bonus is that Power BI Dashboards are interactive, in that you can select records in the table, or items in the charts and the other tables/charts will update accordingly. For example:
Select records in the table
Selected items on the chart
Testing Dashboard if you’re the Creator
On creating my first dashboard using this method it didn’t appear to work and after some time I realised that the creator of the dashboard sees all of the data. This can be a bit confusing – I’ve read it’s because the creator of the dashboard is the owner of the report and the dataset.
There is a method of testing the Dashboard if you’re the creator/owner. Go back to the Power BI application website, open the dataset Security settings:
Then select the RLS item, click on the ellipsis, and click on ‘Test as role’
You can now test the Dashboard using your data:
What Power BI dashboards should not be user for
Power BI dashboards can be made to use live data vis streaming, but the method described above uses data that is updated on a scheduled basis. This means that they shouldn’t replace normal CRM dashboards where the data is refreshed live, i.e. outstanding customers to call.
I hope this gave you a good introduction to Power BI and CRM and what they are capable of in terms the creation of meaningful interactive Dashboards.