Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 13977

Microsoft Dynamics CRM Record Count Reports

$
0
0

I was working with a client the other day that requested help with an SSRS report. You see, this client wanted to create Microsoft Dynamics CRM Record Count Reports. This is accomplished in a Dynamics CRM on-premise environment by creating a SSRS report using an aggregate query to pull data.

Microsoft Dynamics CRM Record Count Reports 1

This will yield the user and the record counts in the report Dataset as needed. This is nice, but it only works for on-premise. On-premise reports are easy. You just write a query to pull the data you need, format the report and there you have it.

However, this question was regarding a Microsoft Dynamics CRM online instance. We must use FetchXML to pull our data. The ChartGuy has a nifty solution to create a chart of multiple entities with FetchXML. The article shows you the tricks to create a chart of entities by owner. The only issue is the limited number of records returned from the FetchXML. FetchXML queries have a limitation of 50,000 records. On-premise SQL queries do not have this limitation.

I’ve run across a few instances with more than 50,000 combined records of Accounts, Contacts, Opportunities and Leads. I know of two Microsoft Dynamics CRM instances with Leads of well over 100,000 and over 500,000 Contact (we’ll not talk duplicates in this article). The ChartGuy’s solution will not work in these instances.

But, we’re trying to find the number of records owned by users. Let’s hope the users/owners do not have 50,000 records. How would they manage all those contacts and leads anyway?

Let’s start by creating a report to count the Account, Contact, Lead and Opportunitiy entities by owner. For this will create a standard SSRS project -- a new report. We’ll want to display this report based on the user record.

Here is the fetch for our User DataSet:

<fetchmapping="logical"aggregate="true">

    <entityname="systemuser" >

        <attributename="systemuserid"groupby="true"alias="User" />

        <attributename="fullname" />

    </entity>

</fetch>

This is our primary search. This will pull all the users in an instance. We can layout the report as needed. But we’re going to add a sub-report to the row. The sub-report will display the records per user. The sub-report will accept a parameter from the parent report of @ownerid. The sub-report will display aggregate values for each entity specified.

Microsoft Dynamics CRM Record Count Reports 2

This is a sample layout. But all you need is a cell/text box to display the values. Above I have a column for Accounts, Contacts, Leads, Cases, Opportunities and a final column with the total of the row. The “Header” row and the fullname column are hidden during rendering. Below is the fetch used to pull the count of accounts per user with the parameter as the filter.

<fetchmapping="logical" aggregate="true" >

   <entityname="account" >

        <attributename="accountid" alias="count_accountid" aggregate="countcolumn" />

        <filtertype="and">

            <conditionattribute="ownerid"operator="eq" value="@ownerId" />

        </filter>

    </entity>

</fetch>

Each entity above is a separate DataSet in the sub-report.  The expression in the box is:

Microsoft Dynamics CRM Record Count Reports 3

The row total is the addition of the cell values.

The parent report displays the User’s name and a merged cell holding the sub-report. The column headings are on the parent report.

Microsoft Dynamics CRM Record Count Reports 4

To get the headings to line up, ensure your cells are the same size by looking at their properties.

The resulting report would look something like this:

Microsoft Dynamics CRM Record Count Reports 5

Again, this is just a quick report to show user record counts. Export the report into a spreadsheet to sort and  manipulate the data as you see fit.

If you have questions regarding this report or other SSRS reports for your instance, give us a shout.

By Sanford Mosby, Microsoft Dynamics CRM Technical Consultant with xRM³, a Microsoft Dynamics CRM Partner located in San Diego, California Southern California.

The post Microsoft Dynamics CRM Record Count Reports appeared first on CRM Software Blog.


Viewing all articles
Browse latest Browse all 13977

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>