CAML In Query Office 365 List Action - Count Distinct Rows

  • 22 January 2015
  • 1 reply
  • 29 views

Hello -

 

I am trying to use Query Office 365 List action and am having a hard time with returning distinct rows.  My list contains multiple columns, but I want to return column 1 and column 2 where distinct.

 

As an example the list contains data such as this. 

 

Column 1 Column 2
Site 1 Red
Site 2 Red
Site 1 Blue
Site 1 Red

 

When I run the CAML query I get 3 records.  I want to consolidate this to only see 2 distinct records.

 

Sample List CAML
Column 1 Column 2
Site 1 Red
Site 1 Blue
Site 1 Red

<View>

    <Query>

        <Where>

            <Eq>

                <FieldRef Name="Service Site"/>

                <Value Type="Text">Site 1</Value>

            </Eq>

        </Where>

    </Query>

    <RowLimit>10000</RowLimit>

</View>

 

I would like to see the following returned, thinking i could use GroupBy to achieve that.  But when I manually type in the CAML it strips out the GroupBy.

 

Sample List CAML
Column 1 Column 2
Site 1 Red
Site 1 Blue

<View>

    <Query>

        <Where>

           <GroupBy collapse="TRUE">

                <FieldRef Name="Service Site" />

           </GroupBy>

            <Eq>

                <FieldRef Name="Service Site"/>

                <Value Type="Text">Site 1</Value>

            </Eq>

        </Where>

    </Query>

    <RowLimit>10000</RowLimit>

</View>

   

 

Is there another preferred method for achieving this?  Or can some provide guidance as to how to accomplish this?

 

Thank you.


1 reply

Userlevel 7
Badge +17

Hi! Just pinging to find out whether you found a solution or still looking for it? If yes (if you found) - can you write here how you achieve that?

Regards,

Tomasz

Reply