3

I'm doing this query:

 SELECT
      ID, Name, Email_Domain__c
    FROM
      Contact
        GROUP BY Email_Domain__c

And I'm getting this error

MALFORMED_QUERY: GROUP BY Email_Domain__c ^ ERROR at Row:5:Column:12 field 'Email_Domain__c' can not be grouped in a query call

Is there a way form to GROUP BY a custom field?

Pretty much what I want to do is in one call, get the domains for all the emails from the Contact object.

UPDATE

When I check this field in workbench, it has these 2 properties

calculatedFormula: RIGHT(Email,((LEN(Email)-(FIND("@",Email)))))

groupable: false
  • I think you answered your own question. – user6861 May 13 '14 at 16:53
  • But, is there a way to make it groupable? – raygo May 13 '14 at 16:53
  • Pretty much what I want to do is in one call, get the domains for all the emails from the Contact object. – raygo May 13 '14 at 16:56
  • I see that formulas of types with "dense" set of expected values are groupable (like boolean or date) while "sparse" types are not groupable (e.g. string, dateTime, double) – hynekcer Nov 5 '14 at 14:41
10

Yes it's possible to group by custom fields in general, but not all field types are groupable.

The docs aren't particularly helpful from what I can see, and just tell you a field is groupable if it's describe field result has a groupable value of true.

IFIRC, you can group by pretty much anything, except DateTime, Long Text Areas, and Formulas, but unfortunately I can't seem to find any explicit documentation of this.

If you want to group by a formula field you can get by with by having creating a copy of the field and having workflow populate it, e.g. whenever your email domain field changes, do a field update that puts the value into the email domain (text) field. You can then use that to group.

0

Can you try this

SELECT Email_Domain__c
    FROM
      Contact
        GROUP BY Email_Domain__c

I agreed to Mr Ralph what is said .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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