Home > CRM > Aggregate Query Record Limit Exceeded – Exception in CRM

Aggregate Query Record Limit Exceeded – Exception in CRM

I was getting below exception when using FetchXML aggregation to compute Average of one of my entities field.

AggregateQueryRecordLimit exceeded.  Cannot perform this operation.

My Fetch XML :

<fetch distinct=’false’ mapping=’logical’ aggregate=’true’>

<entity name=’new-expenses’>

<attribute name=’new_gross’ alias=’gross_avg’ aggregate=’avg’ />



Reason :

  • FetchXML Aggregation has a limitation, by default its limited to performing aggregate queries on less than 50,000 records.

Fix :

  • We cannot change this limit on CRM online
  • On onpremise, we can increase the limit by changing ‘AggregateQueryRecordLimit’ column value of ‘MSCRM_CONFIG.Deployment Properties’ table.
  • Refer this link on how to change.

Aggregation using Fetch XML

One of the major differentiator between Query Expression Vs Fetch Xml is that you can perform Aggregation on result set using Fetch XML.

The following aggregate functions are supported:

  • sum
  • avg
  • min
  • max
  • count(*)
  • count(attribute name)

Refer this link


  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: