Saturday, 16 April 2016

Multiple Aggregates - FetchXML Query

Multiple aggregates can be computed in a single FetchXML query.
Following FetchXML calculates count, sum and avg from opportunity entity.
  1. <fetch distinct='false' mapping='logical' aggregate='true'>
  2. <entity name='opportunity'>
  3. <attribute name='opportunityid' alias='opportunity_count' aggregate='count'/>
  4. <attribute name='estimatedvalue' alias='estimatedvalue_sum' aggregate='sum'/>
  5. <attribute name='estimatedvalue' alias='estimatedvalue_avg' aggregate='avg'/>
  6. </entity>
  7. </fetch>
To calculate multiple aggregate in single FetchXML query
  • Set aggregate to true in fetch node.
  • For each type of aggregate add separate aggregate attribute and set aggregate value accordingly.
- See more at:

1 comment:

  1. Are these commands of sorts? I do not understand any of this. I’d like it if you gave some sort of intro or overview. Thanks a lot.