Microsoft Dynamics CRM and Power BI – Part 2

In the last post we saw how you can connect Dynamics CRM to Power BI and load different entities of CRM into Power BI. Now we will see how you can make relationships between different entities of CRM.

The Power BI Desktop service does not detect or make relationships between the entities automatically so we manually need to create the fields and relationships among them. We will be using the Accounts,Products and Opportunities for this relationship demo.


First of all extract Name, AccountId, Address1_Country,Address1_City, Address1_StateOrProvince and StateCode fields from Account entity of Dynamics CRM using the following OData URL.


Apply necessary transformations and the final query will look like below

final account query


Name this query Accounts.


In the second query we will be extracting the Opportunity data from Dynamics CRM. Since we know upfront what entity set and fields to import we can use the following OData Url to retrieve OpportunityId,CustomerId, PurchaseTimeFrame, EstimatedValue, Name StateCode and EstimatedCloseDate columns.


Note that the PurchaseTimeFrame will be an option set and will have multiple values. To replace these values with some meaningful options please see Map Dynamics CRM Option Set Values into Labels in Power BI.

Also note the EstimatedCloseDate is in UTC format. We need to convert it into local time format. There is a separate post on how you can convert it into local time zone .

The final query will look like below

power BI



In Dynamics CRM an opportunity typically has many products in it. Let’s write one more Query that that extracts all product related data for the opportunities. This data is stored in an entity set called OpportunityProductSet.The URL for this entity set is

https://your-org-url/XRMServices/2011/OrganizationData.svc/OpportunityProductSet?$select=OpportunityId, ProductId, PricePerUnit, Quantity, ExtendedAmount, VolumeDiscountAmount, ManualDiscountAmount

Lets name this Query Products, expand other columns and give them a decent name.


We now have 3 entities loaded from Dynamics CRM into Power BI. Now we need to manage relationships between them. If you click on Manage Relationships in Power BI , you will see the relationship between Products and Opportunities was automatically detected. We just need to define the relationship between Opportunities(CustomerId field) and Accounts(AccountId field). Similarly you can map any relationship between CRM entities using their identity fields.
In the next post we will see how you can visualize and make different reports in Power BI using the CRM data.

1 Comment

Leave a Reply

Request a Free Demo
Enter Your Information below and we will get back to you within few hours