Formula Help! - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Tanya MacKenzieTanya MacKenzie 

Formula Help!

Hi all, 
I created a custom text field that should populate specific text based on multiple criteria from different picklists, using the IF AND functions. Initially, in all cases the criteria was based only on picklist fields, and it has worked perfectly. However, I needed to add a multi select picklist option to the mix of criterias. I tried to nest the INCLUDE function, among oher things in my formula, but to no avail. I ended up creating a separate formula text field, that populated based on the mult select picklist option that was selected in the record. When I try to add that to my formula, it throws various errors. How can I include the formula text field that I created, or directly the multi select picklist option, as part of my formula? 
 

IF(
    AND(formula text field - created from multiselect PL__c)="Specific Text", TEXT(  Picklist1__c  ) = "Specific Text" , TEXT(  Picklist2__c  ) = "Specific Text" ) , "Add this text",
 
IF(
        AND ( TEXT( Picklist1__c ) = "Specific Text" , TEXT( Picklist2__c ) = "Specific Text" , TEXT( Picklist3__c  ) = "Specific Text") , "IF TRUE add this text","IF False add this text"))

Error: Incorrect parameter type for function 'AND()'. Expected Boolean, received Text

 

Thank you! 
 

Best Answer chosen by Tanya MacKenzie
Mikey BrownMikey Brown
Correct, you wouldn't need the OR Statement, if there's only 1 multi-select picklist value you're looking for. 

Are you able to share exact formula you currently have? It should be something like: 
IF(
AND(
   INCLUDES(MultiselectPicklist__c,"Value"),
   ISPICKVAL(Picklist1__c,"Value"),
   ISPICKVAL(Picklist2__c,"Value"),
   ISPICKVAL(Picklist3__c,"Value")),
"Text for True Condition",
"Text for False Condition"
)

 

All Answers

Mikey BrownMikey Brown
Hi Tanya, 

It might help simply things to use ISPICKVAL for your picklist values, and you should be able to use INCLUDES for your multi-select picklist. Within your AND statement you could include an OR Statement for each multi-select picklist value should be included. This would then require than all 3 picklist equal the specific text and the multi-select picklist field includes at least 1 of the values listed in your OR Statement. 
 
IF(
AND(
   OR(
      INCLUDES(MultiselectPicklist__c,"Value1"),
      INCLUDES(MultiselectPicklist__c,"Value 2")),
   ISPICKVAL(Picklist1__c,"Specific Text"),
   ISPICKVAL(Picklist2__c,"Specific Text"),
   ISPICKVAL(Picklist3__c,"Specific Text")),
"Text for True Condition",
"Text for False Condition"
)

Thanks,
Mikey
 
Tanya MacKenzieTanya MacKenzie
Thank you Mikey.  The result will be dependant on only one option from the multi select picklist, so I don't believe the OR function is needed. I also tried replacing TEXT with ISPICKVAL, and had the same result. It could be related to the syntex of the IF, AND, INCLUDES and TEXT functions together?
Mikey BrownMikey Brown
Correct, you wouldn't need the OR Statement, if there's only 1 multi-select picklist value you're looking for. 

Are you able to share exact formula you currently have? It should be something like: 
IF(
AND(
   INCLUDES(MultiselectPicklist__c,"Value"),
   ISPICKVAL(Picklist1__c,"Value"),
   ISPICKVAL(Picklist2__c,"Value"),
   ISPICKVAL(Picklist3__c,"Value")),
"Text for True Condition",
"Text for False Condition"
)

 
This was selected as the best answer
Tanya MacKenzieTanya MacKenzie
Thanks so much Mikey, for your help !  I rewrote my formula to match yours above and it worked great. It populated the multi-select picklist option as it should, as well as the other criteria. 
Mikey BrownMikey Brown
Awesome! I'm glad you were able to get it working. Just let me know if you ever need help making any other tweaks to it.