0

I have a few multipicklist field in my contact and i would like to report on how many values selected for these fields per contact in report. Is that possible?

1 Answer 1

1
  1. Create a number field with 0 decimal places named Count_Of_Selections__c
  2. Create a text field named anything you want
  3. Create a WFR that copies the value of the MSPL to the text field in #2
  4. Create a WFR to populate that field with the count of items

LEN( Name)-LEN(SUBSTITUTE(Name,";",""))/LEN(";")+1

replacing NAME with your field from #2

  1. Use the field in #1 in your report

or you can follow the instructions here:

https://help.salesforce.com/HTViewSolution?id=000221353&language=en_US

But you have to updated the formula each time you add valued to the picklist and the compile size might be too big if you have a lot of values

Navigate to the fields area of the appropriate object.

  1. For standard objects, from Setup, click Customize, select the appropriate object, and click Fields.
  2. For custom objects, from Setup, click Create | Objects, and select one of the custom objects in the list.
  3. In Custom Fields & Relationships, click New.
  4. Choose the Formula as the type and click Next
  5. Enter a field label(Salesforce populates Field Name using the field label)
  6. Select the Formula Return Type as Number
  7. Choose the number of decimal places as 0
  8. Select the Advanced Formula
  9. To insert a function, double-click its name in the list, or select it and click Insert Selected Function

              IF(INCLUDES( Multi_Picklist_Field__c , "Value A"),1,0) +
              IF(INCLUDES( Multi_Picklist_Field__c , "Value B"),1,0) +
              IF(INCLUDES( Multi_Picklist_Field__c , "Value C"),1,0) +
              IF(INCLUDES(  Multi_Picklist_Field__c , "Value D"),1,0)
    
  10. To check your formula for errors, click Check Syntax and Save.

Basically there is no clean way to do it declaratively. A trigger could populate it much easier

trigger countItems on Account(before insert, before update){

     for(Account a : trigger.new){
          if(string.isblank(a.PICKLISTFIELD__c)) continue;
          a.MYCOUNTFIELD__c = a.PICKLISTFIELD__c.split(';').size();

     }

}
2
  • Multi-select picklist fields can only be used in these functions: INCLUDES ISBLANK ISNULL ISCHANGED PRIORVALUE
    – o-lexi
    Oct 11, 2016 at 17:46
  • @Oleksiy - Thanks for pointing that out. Updated answer.
    – Eric
    Oct 11, 2016 at 19:45

You must log in to answer this question.

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