Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6616361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:34:24+00:00 2026-05-25T20:34:24+00:00

I am using FetchXML and I am grouping and using count for two of

  • 0

I am using FetchXML and I am grouping and using count for two of the entities but the rest of the entities I don’t need grouped I just need the data to be pulled down. For example this is my code:

string groupby1 = @" 
<fetch distinct='false' mapping='logical' aggregate='true'> 
 <entity name='opportunity'>
  <attribute name='name' alias='opportunity_count' aggregate='countcolumn' />  
  <attribute name='ownerid' alias='ownerid' groupby='true' />
  <attribute name='createdon' alias='createdon' /> 
  <attribute name='customerid' alias='customerid' /> 
 </entity> 
</fetch>";

EntityCollection groupby1_result = orgProxy.RetrieveMultiple(new FetchExpression(groupby1));

foreach (var c in groupby1_result.Entities)
{
  Int32 count = (Int32)((AliasedValue)c["opportunity_count"]).Value;
  string OwnerID = ((EntityReference)((AliasedValue)c["ownerid"]).Value).Name;
  DateTime dtCreatedOn = ((DateTime)((AliasedValue)c["createdon"]).Value);
  string CustomerName = ((EntityReference)((AliasedValue)c["customerid"]).Value).Name;
}

But I get this error:

EXCEPTION: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: An attribute can not be requested when an aggregate operation has been specified and its neither groupby nor aggregate. NodeXml : (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).

How do you use aggregates on some values and not others?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:34:25+00:00Added an answer on May 25, 2026 at 8:34 pm

    The error message is giving you the answer – this isn’t possible with FetchXML. You’ll need to make two FetchXML calls; one for your aggregates and one for your data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am querying data from CRM 2011 using FetchXML to build a report in
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using C#, I need a class called User that has a username, password, active
How do i do a left join using FetchXml? Consider a simple SQL query
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
I am using FetchXML in SSRS 2008 to create a report from CRM 2011.
I am using NSURLConnection to fetch XML data from the server. I am parsing
Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I
Using gcc and ld on x86_64 linux I need to link against a newer
Using the current request I can get the URL hostname with: HttpContext.Current.Request.Url.Host But -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.