+ Start a Discussion
VIGNESH BALASUBRAMANIANVIGNESH BALASUBRAMANIAN 

Cannot group by a currency field in SOQL

Hi Everyone,

I could not group by a currency field in SOQL,
Select count(id),currency__c from contact group by currency__c
It shows the following error,

field 'currency__c' can not be grouped in a query call

Kindly provide me a solution,

Thanks 
Vignesh
Best Answer chosen by VIGNESH BALASUBRAMANIAN
LBKLBK
Hi Vignesh,

Not all the fields are groupable in SOQL.

I believe Currency type field is certainly not one of them.

You can run this code to get the detailed description on your field.
system.debug(Contact.currency__c.getDescribe());
You will be seeing a boolean attribute isGroupable is set to false in this case.

If your use case for grouping the data by currency__c field is unavoidable, I suggest you to use an additional field which will store the value in currency__c field in TEXT type and use that in GROUP BY.

I am afraid this is the only way around here.

Let me know if this helps.