I have a working aggregate result class with a wrapper. Have made a couple of data sets pulled from cases and campaigns to get aggregate results of participants of both by date and other fields. Mostly querying fields on contact. All are working great expect multiselect picklists. Im resigned to not using an aggregate result but actually I can seem to get any results back. I've tried using split, includes, escapes, variables and even bludgeoning it out into a list to count. Evidently not in the right combinations. I'm totally open to putting it in a class of it's own with any kind of output. Probably need a break. Any help would be amazing. here is an early version of the code, before I tried everything and nothing worked... I can get a simple list out of exec anon. Definitely when there is more than one option selected there's a ;- which cannot see to be escaped and when I try to split it I get error messages that split is not a valid method on string...

 public List<ExWrapperX> getGenerateAgeR3(){  
        list<ExWrapperX> r3QueryTotals = new List <ExWrapperX>();
        List<AggregateResult> rRange3 =[SELECT race__, ID 
                                        FROM Contact
// use ids pulled from case and campaign- setconcurrent and prior
                                        WHERE ID IN : setConCurrent
                                        AND ID NOT IN : setConPrior
                                        AND Race__c INCLUDES ('Asian;')
        System.debug('age - # of IDs after rRange3 query runs' + rRange3.size());
       //removed loop as it's long

  r3QueryTotals.add(new ExWrapperX(String.valueOf(a.get('ln')), (Integer.valueOf(a.get('kidz')))));    

        return r3QueryTotals; 

Tried things like this but cannot seem to put it together correctly 
Account a = [Select AMSPICKLIST__c From account Limit 1];

String[] tmpString = a.AMSPICKLIST__c.split(';');

For(Stirng s : tmpString)
  • 1
    Unless there is actually a ; character in your option value, you should just use INCLUDES('Asian').
    – Adrian Larson
    Jul 27, 2016 at 2:35

1 Answer 1


Take a look at Querying Multi-Select Picklists. You only need to include a ; character if you're trying to match multiple options.

Specifies AND for two or more strings. Use ; for multi-select picklists when two or more items must be selected. For example:


For one value, just use the option value itself:

Race__c INCLUDES ('Asian')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .