Announcements
No record found.
Hi,
Is there any way to aggregate data (e.g. return average order value across all orders for a given customer) using the common data services web api, or do I have to retrieve each individual record and perform the aggregation in my code?
Hi!
Here is the information to do the aggregation:
Aggregate and Grouping results
docs.microsoft.com/.../query-data-web-api
Regards.
You could create rollup field to get the aggregate value and use this field in webapi to show wherever you want.
Please see below link to check how to setup rolup field in Dynamics CRM.
https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/customize/define-rollup-fields
Hi Tim,
You can aggregate data using Web API.
You can refer to:
https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/query-data-web-api#aggregate-and-grouping-results
Here are steps that follow your example (return average order value across all orders for a given customer).
1.This is all orders.
You can directly calculate average of all orders is 35354.3333. And the average is 20065.5 when the given customer named Jim Glynn(sample).
2.using Web API.
(1) calculate all orders.
salesorders?$apply=aggregate(totalamount with average as averagevalue)
(2) calculate orders that given customer named Jim Glynn(sample).
salesorders?$apply=aggregate(totalamount with average as averagevalue) &$filter=_customerid_value eq '491a2f1a-628e-ea11-a811-000d3a35bad3'
Regards,
Clofly
Thanks - I was looking under "Function" and "Query Function" in the web api reference which is why I didn't find it!
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
ManoVerse 128 Super User 2026 Season 1
11manish 97
Muhammad Shahzad Sh... 69 Most Valuable Professional