function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Priyadarshini Manoharan 3Priyadarshini Manoharan 3 

Can we compare 2 multi-select picklist fields in a formula field? If so how?

Can we compare 2 multi-select picklist fields in a formula field? If so how?
Best Answer chosen by Priyadarshini Manoharan 3
Priyadarshini Manoharan 3Priyadarshini Manoharan 3
Hi Prosenjit,

Thanks for your help, a combination of ISPICKVAL and INCLUDES worked!
Salesforce support too helped with this.
Below is the solution

IF( 
AND( 
ISPICKVAL(Product__c, "Nike"), 
INCLUDES( $User.Product_Access__c, "Nike") 

, "Y", 
IF( 
AND( 
ISPICKVAL(Product__c, "Reebok"), 
INCLUDES( $User.Product_Access__c, "Reebok") 

, "Y", 
IF( 
AND( 
ISPICKVAL(Product__c, "Bata"), 
INCLUDES( $User.Product_Access__c , "Bata") 
), 
"Y", "N" 


All Answers

Prosenjit Sarkar 7Prosenjit Sarkar 7
Yes we could. But it totally depends on your requirement. PLease follow this link https://help.salesforce.com/apex/HTViewHelpDoc?id=tips_for_using_picklist_formula_fields.htm&language=en_US (https://help.salesforce.com/apex/HTViewHelpDoc?id=tips_for_using_picklist_formula_fields.htm&language=en_US" target="_blank) .

If you still confused after reading this link, please share your requirement we can try that out.

Thanks :) 
Priyadarshini Manoharan 3Priyadarshini Manoharan 3
Hi Prosenjit,

Thanks for the links above. I had gone through these, but they did'nt help.

The requirement is at User level there are 2 fields Account and Product which are multi-select picklist fields, which are nothing but the user's account and product and at the case level there is account and product which are lookup fields, I am trying to create a formula field which compares the account at user level with account at case level and products at user levels with product at user level if both match then the formula field would return Y and this formula I would use in the View filter to filter cases as per the logged in user's Account and Products.

Thanks
Priya
Priyadarshini Manoharan 3Priyadarshini Manoharan 3
This is the formula field I am trying on Case object
IF( Account.Name ==  $User.Account__c, "Y",
IF( $User.Product_Access__c == Product.Name, "Y","N")
)

I am getting this error
 Error: Field Product_Access__c is a multi-select picklist field. Multi-select picklist fields are only supported in certain functions.

Is there any workaround to achieve this functionality through formula field?
Prosenjit Sarkar 7Prosenjit Sarkar 7
Hi Priya,
Please try with this,
IF( Account.Name ==  TEXT($User.Account__c), "Y",
IF( TEXT($User.Product_Access__c) == Product.Name, "Y","N")
)

Thanks :)
Priyadarshini Manoharan 3Priyadarshini Manoharan 3
Hi Prosenjit,

Thanks for helping.

I get the below error

Error: Incorrect parameter type for function 'TEXT()'. Expected Number, Date, DateTime, Picklist, received Tex

I too tried this :) moreover I think TEXT is for single value picklist and not multi select picklist.

Any other ideas are welcome :)

Thanks
Priya
Prosenjit Sarkar 7Prosenjit Sarkar 7
Hi Priya,
Have tried with INCLUDE ?
IF( INCLUDE($User.Account__c, Account.Name), "Y",
IF( INCLUDE($User.Product_Access__c, Product.Name)  , "Y","N")
)
Thanks :)
 
Priyadarshini Manoharan 3Priyadarshini Manoharan 3
Hi Prosenjit,

Thanks for your help, a combination of ISPICKVAL and INCLUDES worked!
Salesforce support too helped with this.
Below is the solution

IF( 
AND( 
ISPICKVAL(Product__c, "Nike"), 
INCLUDES( $User.Product_Access__c, "Nike") 

, "Y", 
IF( 
AND( 
ISPICKVAL(Product__c, "Reebok"), 
INCLUDES( $User.Product_Access__c, "Reebok") 

, "Y", 
IF( 
AND( 
ISPICKVAL(Product__c, "Bata"), 
INCLUDES( $User.Product_Access__c , "Bata") 
), 
"Y", "N" 


This was selected as the best answer
Priyadarshini Manoharan 3Priyadarshini Manoharan 3
It was comparing single value picklist with multi select picklist, and not 2 multi-select picklist. However similar logic could be used for 2 multi-select picklist
Prosenjit Sarkar 7Prosenjit Sarkar 7
Great job @Priya :)