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
Nadia AyoubNadia Ayoub 

Image Formula field based on Picklist Value

Hi,

I'm fairly new to formula fields and am having trouble with this one. I want to display various images depending on which picklist value is chosen.  Here is one formula I've tried, and am getting a very confusing error message :( 

Error: Incorrect number of parameters for function 'ISPICKVAL()'. Expected 2, received 9

Could anyone guide me in the right direction? Thanks!

IMAGE (
ISPICKVAL (
Contact_Status_Data__c,
   "Active", "img/msg_icons/confirm32.png",
   "Inactive", "img/msg_icons/error32.png",
   "Non-Serviced", "img/msg_icons/warning32.png",
   "No Volume", "img/msg_icons/info32.png"
))
Best Answer chosen by Nadia Ayoub
kaustav goswamikaustav goswami
ISPICKVAL function accepts two parameters - the picklist field name and the picklist value against which it will match the current value.

For your case - you will need to use a nested if formula.

Something like this

IMAGE(
  IF(ISPICKVAL(Contact_Status_Data__c, "Active"), "img/msg_icons/confirm32.png",
      IF(ISPICKVAL(Contact_Status_Data__c, "Inactive"), "img/msg_icons/error32.png",
          IF(ISPICKVAL(Contact_Status_Data__c, "Non-Serviced"), "img/msg_icons/warning32.png"),
              IF(etc....))
)
)


Or you can also try out the case formula that will be much more easier

IMAGE(
CASE(Contact_Status_Data__c,
"Active", "img/msg_icons/confirm32.png",
"Inactive", "img/msg_icons/error32.png",
"Non-Serviced", "img/msg_icons/warning32.png",
"No Volume", "img/msg_icons/info32.png",
"/s.gif"),
"contact status")

Thanks,
Kaustav

All Answers

kaustav goswamikaustav goswami
ISPICKVAL function accepts two parameters - the picklist field name and the picklist value against which it will match the current value.

For your case - you will need to use a nested if formula.

Something like this

IMAGE(
  IF(ISPICKVAL(Contact_Status_Data__c, "Active"), "img/msg_icons/confirm32.png",
      IF(ISPICKVAL(Contact_Status_Data__c, "Inactive"), "img/msg_icons/error32.png",
          IF(ISPICKVAL(Contact_Status_Data__c, "Non-Serviced"), "img/msg_icons/warning32.png"),
              IF(etc....))
)
)


Or you can also try out the case formula that will be much more easier

IMAGE(
CASE(Contact_Status_Data__c,
"Active", "img/msg_icons/confirm32.png",
"Inactive", "img/msg_icons/error32.png",
"Non-Serviced", "img/msg_icons/warning32.png",
"No Volume", "img/msg_icons/info32.png",
"/s.gif"),
"contact status")

Thanks,
Kaustav

This was selected as the best answer
Nadia AyoubNadia Ayoub
Yay it worked. Thanks so much Kaustav!!!
john s.john s.
Hello Guys,

Some Question Occours for myself 

What is this part in the formula code   "contact status" .

I understand  everything but not the last row from the formula code ... 

best regards john s. 





 
Boaz Sherez 1Boaz Sherez 1
Thanks Kaustav!
 It's possible to do the same but also by month?
Like - put the image only if it's the last month? Or May month?
Sprutiraj Panda 7Sprutiraj Panda 7
Hi 
ya i got the above formula so i have one concern if there are 3 picklist filed than at that case what will be work.like 
for ex- Adm201 ,pD-1,pd2 3 picklist are there if Adm201 is certified the image came if not another image so like that pd1 & Pd2 image aslo came in at one time ...
so how can we do this please help me on this