Activity Forums Salesforce® Discussions Formula Field in Aggregate Salesforce Query

  • Ajit

    March 30, 2016 at 11:48 am

    Can any body suggest me how can i use the formula field in a aggregate soql query because when i am using the field it is throwing error that this field can't be grouped or aggregated


    select count(id), formula__c from Object__c group by formula__c

  • Suyash

    March 30, 2016 at 11:55 am

    Hello Ajit,

    Formula fields are not "groupable" i.e they are not usable in the GROUP BY clause of a SOQL query.

  • Ravi

    March 30, 2016 at 1:47 pm

    Hi Ajit,
    Formula Fields cannot be used with the group by clause in SOQL query
    You can check whether a field is "groupable" or not using DescribeFieldResult.
    Schema.DescribeFieldResult resultObject= Object__c.formula__c.getDescribe();
    if(resultObject.groupable == true){
    formula__c is groupable
    formula__c is not groupable

    • This reply was modified 5 years, 10 months ago by  Ravi.
  • Parul

    September 7, 2018 at 12:19 pm

    Hi Ajit

    To Check whether any field is "groupable" or not,Please follow the below procedure

    Schema.DescribeFieldResult fieldDescribe = ObjectName.FieldName.getDescribe();

    if(fieldDescribe.groupable == true){

    Then Our Field is Groupable



  • William

    November 12, 2018 at 4:33 am

    Formula fields are not "groupable" - that is, they are not usable in the GROUP BY clause of a SOQL query. There is limitation like Formula fields can't use in the group by Clause.

  • Divya

    November 19, 2018 at 5:19 am


    Formula fields are not groupable  they are not usable in the GROUP BY clause of a SOQL query.

Viewing 1 - 6 of 6 posts

Log In to reply.

Popular Salesforce Blogs