I'm updating a view on an existing list programmatically but I can't get the aggregation to work correctly. I'm setting it as follows (the values are pulled from an xml site definition):

if (AggregationStatus == "On")
    view.Aggregations = "<FieldRef Name=\"" + AggViewField.Name + "\" Type=\"" +      AggViewField.Type + "\"/>";
    view.AggregationsStatus = AggregationStatus;
  ... more settings here ...

And if I look at the list with SharePoint Manager I can see the aggregation has been applied as follows:

 <Aggregations Value="On">
      <FieldRef Name="LinkFilename" Type="Count" />

Which looks correct to me, but on the site itself the aggregation shows as "Count= undefined". If I modify the view I can see that the Count total is set for the name column and if I now save the view without changing anything the aggregation works properly, which makes me wonder if the view.Update() isn't doing what I think it is. Do I need to update the list as well? Is there some kind of SP_voodoo required to get an aggregation to work?

Any suggestions gratefully accepted.

This is SharePoint 2013 Enterprise on premises and my solution is using VS 2012

1 Answer 1


I was looking for an answer to this today. It appears to work if the type is in capitals.

So use:

<Aggregations Value="On">
  <FieldRef Name="LinkFilename" Type="COUNT" />

instead of:

<Aggregations Value="On">
  <FieldRef Name="LinkFilename" Type="Count" />

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.