views:

2787

answers:

2

Hello,

I'm trying to get data from a Sharepoint list and put it into some Flex graphs. I can call the list data just fine using a CAML query, but I want to use a GroupBy to consolidate the rows by Teams. So, for example Team 1 may have 20 records, Team 2 may have 8 records, and Team 3 might have 25 records... Instead of showing 53 records, I want to show 3... just "Team 1, Team 2, Team 3" and the sum of the cost of each entry.

I see where CAML provides a GroupBy element, but I can't seem to get it to work. Also, I was only able to get the OrderBy element to work when I used the OrderField element instead of the FieldRef element like 90% of the books and websites recommend. If I do use FieldRef, OrderBy doesn't work anymore, which makes no sense to me. Something must be awry...

Here is my CAML Query as it stands...

---------------------------------------------------

<queryRequest xmlns="http://schemas.microsoft.com/sharepoint/dsp"&gt; 
<dsQuery resultContent="dataOnly" resultRoot="Rows" resultRow="Row" columnMapping="attribute">
<ViewFields> 
<FieldRef Name="Team"></FieldRef> 
<FieldRef Name="Cost"></FieldRef> 
<FieldRef Name="EANo"></FieldRef> 
</ViewFields> 
<Query> 
<GroupBy collapse="true"> 
 <FieldRef Name="Team"/>
</GroupBy> 
<OrderBy>
 <OrderField Name="Cost"/>
</OrderBy>
</Query> 

</dsQuery>
</queryRequest>
---------------------------------------------------

This is with OrderBy working, but GroupBy not working. Help!

Thanks!

+1  A: 

I ran the following query and seems to be working fine for me.

<Query>
   <GroupBy collapse="true">
      <FieldRef Name='Date' />
   </GroupBy>
   <OrderBy>
      <FieldRef Name='Title' />
   </OrderBy>
</Query>

I suggest you use the U2U CAML Query Builder tool to build and test your query's

Ganesha
U2U CAML Query Builder Link: http://www.u2u.be/Res/Tools/CamlQueryBuilder.aspx
ongle
A: 

Same problem! Previous code doesnt do the grouping. Need Help! Please! TIA

Paulo Sousa