We have a SharePoint list with Duration (type:number) and Score (type :number, value:1-5) column.
We want to display sum of all duration and average of all score's on the Home page.
I am aware that I can achieve this by fetching all the items (using rest api) on page load and then calculating sum and average.
Is there any in built rest endpoint or a caml query that can directly fetch me the value. SharePoint does calculate sum and average for a view in Totals section.
Thanks in advance.
1 Answer
There is no JSOM or REST or even SSOM C# way of getting the Sums or totals for groups.
SharePoint can show averages in the Datasheets only and totals in the groups are retrieved using some internal methods. But for common mortals these methods are not exposed. When I had to get the group totals back in the day I had to render the SPGridView on the server, parse the HTML and and 'steal' the group totals this way. That was the only way.