2

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

  • do you want to sum the columns or you want to do the sum of the list items? – Niranjan Kulkarni Apr 27 '16 at 4:31
  • I need to group by name and sum of the remaining column values (list items). – user53701 Apr 27 '16 at 8:52
3

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

Thanks

1

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.