I have a sharepoint list with 4 columns one with the name and rest all with the numbers. I need to groupby name and need to sum the remaining columns. Please help me how it can be achieved using REST API
I was having the same query which you have. But unfortunately i found that REST Service does not supports GROUP BY functionality as per this REST Service
But not to worry, you can still achieve this just you need to do some extra stuffs. The methodology which i used was
- Get all data from REST Service.
- Created a function which do required GROUP BY operation.
For more detail you can refer this post How to group distinct values from a list using odata rest api
I followed the above post and i was able to achieve what i want. So it may help to solve your requirement too.
The second approach i just found it may help.
We can use our CAML query with REST Service API as mentioned here Using CAML with SharePoint API. We can build our CAML GROUP BY statement and then get executed by REST Service API call.
If you need to get detail about CAML expression you can found reference here CAML Query Schema
You cannot use REST Service API call to sum up your list items as REST Service API calls do not support aggregate function.
You can get data from REST Service API and perform aggregate function using client side scripting.For more information you can refer this Use REST to sum a column?