2

Is there any way to Group By part of string in SOQL.

For example something like:

Select Id, Name from Object__c group by Name.substringBetween('.','.')

So query by part of a string field and not the whole field.

The other approach that can be taken to this is to create a formula field that takes the substring between the name field, and then use that field in the group by, if there is no other option.

Thanks in advance.

  • Is that my answer serves your purpose? – Santanu Boral Sep 11 '17 at 21:37
8

If you really want to use specific field values in GROUP BY then create a text field and update the text field either by workflow rule or Process builder or trigger.

Formula field is not supported in Group By clause.

There is an idea Allow SOQL GROUP BY on formula fields posted, you could vote for this idea.

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.