1

I got error like this :

[System.UnexpectedException: field 'IKAM_Year__c' can not be grouped in a query call]

how can I resolve this error? can anybody help me.

class:

public Month[] getMonths() {
    Month[] months = new Month[] {};
    for (AggregateResult ar : [select count(Id) ,IKAM_Year__c,Countries_delivered_volume__c from IKAM_Data__c
                                              group by IKAM_Year__c, Countries_delivered_volume__c LIMIT 10                        
    ]) {                                        
        months.add(new Month((Decimal )ar.get('IKAM_Year__c'),(Decimal)ar.get('Countries_delivered_volume__c')));
    }
    return months;
}
1

From the SOQL documentation on Considerations When Using GROUP BY,

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

Specifically, you could see whether or not your field is able to be used with GROUP BY by running the following code:

system.debug(IKAM_Data__c.IKAM_Year__c.getDescribe().groupable);
| improve this answer | |

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.