ShowAll Questionssorted byDate Posted
tgk1

# Formula for multi-select picklist

Hi everyone.  I have a multi-select picklist that contains roughly 50 values.  I need to create a simple formula field that counts the number of values that were marked off in the mult-select picklist.

For instance, if two values were selected in the mult-select picklist, the value of the formula field would equal 2.

I know this seems simple but I'm having trouble due to the field type.  Any help would be greatly appreciated.

Shashikant Sharma

As multiselect-picklist only supported in some limited functions so it will be prety difficult to create a formula, not saying it is imposible. bUt better solution is to just calculate it a trigger.

try this

```trigger CalculateCountMultiSelect on MyObject__c ( before insert , before update)
{
for(MyObject__c obj : trigger.new)
{
List<String> l =﻿ new List<String>();
if(obj.MultiPickList__c﻿ != null)
{
l = obj.MultiPickList__c﻿.split(';')
}
obj.count__c =    l.size();
}
}```

replace you object and field name for multi-select picklist

Count__c is you Number field.

Shashikant Sharma

As multiselect-picklist only supported in some limited functions so it will be prety difficult to create a formula, not saying it is imposible. bUt better solution is to just calculate it a trigger.

try this

```trigger CalculateCountMultiSelect on MyObject__c ( before insert , before update)
{
for(MyObject__c obj : trigger.new)
{
List<String> l =﻿ new List<String>();
if(obj.MultiPickList__c﻿ != null)
{
l = obj.MultiPickList__c﻿.split(';')
}
obj.count__c =    l.size();
}
}```

replace you object and field name for multi-select picklist

Count__c is you Number field.

This was selected as the best answer
Ankit Arora

Here is the blog post which says similar thing you want. But its good to do with 4-5 values, as you have 50 then I also suggest you to go with apex.

Thanks

Ankit Arora

tgk1

Excellent- the trigger worked great.  Thanks everyone.

multi picklist validation rule

Great job Mr.sharma

Shashikant Sharma

Thnaks Mate,

Even though i am not in touch with developer community these Days, but happy to know my earlier work still has some wires connected.