Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to use an aggregate query, but one of the fields I want to group by is not groupable (saw it in the soql error and then verified groupable=false in the metadata).

It's just a number field that holds an integer (number 2,0 in salesforce field spec-speak).

Is there a trick to make it groupable? Any way around this problem? I don't want to write hundreds of lines of code just to average a list by this field.

share|improve this question
Can you provide more specific detail about the configuration of the custom field which you are trying to group by? Support for Field Types in Aggregate Functions – Mark Pond Dec 31 '12 at 20:28
up vote 5 down vote accepted

I'm not 100% sure what makes it "groupable". The Considerations When Using GROUP BY does mention it:

Some object fields have a field type that does not support grouping. You can't include fields with these field types in a GROUP BY clause. The Field object associated with DescribeSObjectResult has a groupable field that defines whether you can include the field in a GROUP BY clause.

Although not exactly elegant, you could try to copy the not groupable field to a groubable field via a workflow rule and then group by that one instead.

share|improve this answer
Did the extra field copy with a workflow. Salesforce seems arbitrary sometimes. – Shane McLaughlin Jan 1 '13 at 19:41

It appears that you can not group by custom number fields and not the ability to group by formulas is a request on the ideaexchange so you will need to create a workflow rule that copies the number to a text field.

Note that most standard number fields cannot be grouped by as well but a few like account.numberofemployees can be.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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