I have a lookup column and i want to use groupby for that lookup column in rest api. Anyone suggest me how to do this?

  • I didn't get you, what do you mean groupby for lookup column? Can you please explain by giving any example from you list data? Commented Sep 17, 2019 at 10:24
  • /items?$select=Member/Title&$expand=Member&$groupby=Member_x003a_StatusCal in this rest call Member:StatusCal is lookup column, Is this what you are looking for? Commented Sep 17, 2019 at 12:41

1 Answer 1


We can use CAML query with REST API to group by list items.

Example code:

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
    var listName="TestList";
    var fieldName="LookupField";
    var viewXml ="<View><Query><GroupBy Collapse='TRUE'><FieldRef Name='"+fieldName+"'/></GroupBy></Query></View>";

    var camlQuery={"query" :{"__metadata": { "type": "SP.CamlQuery" }, "ViewXml": viewXml}};
        url:  _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('"+ listName +"')/GetItems",                          
        type: "POST",
        data: JSON.stringify(camlQuery),
        headers: { 
            "Accept": "application/json;odata=verbose",
            "content-type": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        success: function(data){
        error: function (data) {
            console.log("Failed to get details");
<div id="Test"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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