Forum Discussion
Connecting to CRM saved views
Hi v-ljerr-msft\ Anonymous,
Well Powershell can do this using "Microsoft.Xrm.Data.PowerShell" library, there should have been some funtionality in Power bi.
Right now our current architecture is like we are using powershell to call crm saved user views then data is exported to our local machine in the form of .csv file then we upload data from csv file to Power bi so all this is a manual process.
We need to make this automated like there should be some way where we don't have to export csv file and upload in Power Bi and there should not be manual refresh, all should be automated.
Please suggest some best and effective solution to achieve this( like related to Azure,Powershell, C#, Sharepoint and so on)
harsh as I suggested earlier, you can query that UserQuery table and get the FetchXML code for those views. Then you can translate that into SQL and use those SQL statements as a starting point for queries in Power BI. Setting them up for the first time is a manual process but after that Power BI will simply refresh its data to pull that view.
- harsh9 years ago
Helper I
Sorry Anonymous, I don't know how to do this, could you please help me by showing steps/snapshots ?
Right now one thing I tried while making connection, I called the tables and its columns, however this is TEDIUS TASK.
https://cne*********.com/XRMServices/2011/OrganizationData.svc/EE_programenrollmentSet?$filter=statecode/Value eq 0&$select=EE_EngagementRating,EE_CustomerEvidence,EE_NomindatedById,EE_AccountId
This will bring only that data which I want.
- Anonymous9 years agoNot applicable
Once you connect, you can just make queries in Power BI that replicate your list views. Pick the table you want, then go through all the normal steps of choosing columns to keep, filtering the results, etc. You'll be recreating those list views from scratch. Annoying but not too difficult. The FetchXML method I suggested is no less tedious, but it is an alternative.
If you want to get the existing list view queries from CRM and translate them, you need to first connect and query the UserQuery table in the query editor. Look for the row with the name of the view you want to replicate and find the FetchXML column. Take the text from that cell and run it through a FetchXML to SQL translator. This one is pretty good. Take the resulting SQL and go back to the query editor in Power BI. Add a new blank query and open the Advanced Editor. In that window write a query that looks like this:
let Source = Sql.Database( "nameOfSQLServerGoesHere", "nameOfDatabaseGoesHere", [Query="stuff from the FetchXML to SQL converter goes here"] ) in SourceThat will approximately give you the list view as a Power BI query. There are some odd quirks to FetchXML though. Whichever column or columns in CRM were chosen as the sort order for the list view may be left out of the SELECT list in the resulting SQL. They end up in a GROUP BY argument instead, so you might need to add those columns to the SELECT yourself.
Usually it's going to be easier to just build a new query in the query editor the same way as connecting to any other source. If you're not familiar with that method you need to check out some basic tutorials on using Power Query. Sometimes translating the FetchXML can be a useful alternative, for instance if you have a really complicated list view and you're not familiar with where it's getting everything.
- harsh9 years ago
Helper I
let Source = Sql.Database( "nameOfSQLServerGoesHere", "nameOfDatabaseGoesHere", [Query="stuff from the FetchXML to SQL converter goes here"] ) in SourceNot sure why you have specified sql database instead of crm, one thing which I find it as a flaw is while connecting to crm and while loading data, its too slow it takes more than 30 min to load data while from csv it takes less than a min.
Well I 'm thinking to have a powershell script which will be on Azure and that would be scheduled which will pull data from CRM and export in csv format somewhere in azure, same will be uploaded in Powerbi from Azure and then data gets automatically refreshed from Azure, Is this feasible please share your thoughts and if you have any smarter way to do this, let me know