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
MokshadaMokshada 

how to show image of ratings based on picklist using formulas.

I want to create one picklist namely rating and having values 1,2,3,4,5 and we have five images of 1 star , 2 star etc upto 5 star and wanted to create one image formula field where we will be able able to see images which we have from 1 star to 5 star.
How to acieve this?

Thanks
Best Answer chosen by Mokshada
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Mokshada,

There was syntax error in If() statemnets. Can you try below.
 
If(TEXT( Ratings__c )= '1' , IMAGE("/resource/OneStar", "ONE", 24, 24), 
If(TEXT( Ratings__c )= '2' , IMAGE("/resource/TwoStars", "TWO", 24, 24), 
If(TEXT( Ratings__c )= '3' , IMAGE("/resource/ThreeStar", "THREE", 24, 24), 
If(TEXT( Ratings__c )= '4' , IMAGE("/resource/FourStar", "FOUR", 24, 24), 
If(TEXT( Ratings__c )= '5' , IMAGE("/resource/FiveStar", "FIVE", 24, 24), 'SAMPLE')))
))

If this solution helps, Please mark it as best answer.

Thanks,

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Mokshada,

You can upload the images in static resources and use them in formule as below.

I just tried it for Picklist with 1 if remaining vaules are selected it gives Sample as text in the formula. If 1 is selected it shows the image  as shown below.
 
If(TEXT( rating__c )= '1' , IMAGE("/resource/sasas", "ONE", 24, 24), 'SAMPLE'
)
User-added image
Similarly you can do multiple if statements or Case to achive it.

Please find the article (http://bestirtech.com/blog/2019/02/displaying-images-in-formula-fields-in-salesforce/) for the same.
I have used "Images from Static Resources:" in the above link.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
 
CharuDuttCharuDutt
Hi Mokshada,
Try Below Formula
If Using Static Resource
IF(TEXT( Stage )= 'Prospect' , IMAGE("/resource/prospect", "ONE", 24, 24), 'SAMPLE'
)
Please Mark It As Best Answer If It Helps
Thank You! 
MokshadaMokshada
Hi praveen,

I have written like ,
If(TEXT( Ratings__c )= '1' , IMAGE("/resource/OneStar", "ONE", 24, 24), 'SAMPLE',
If(TEXT( Ratings__c )= '2' , IMAGE("/resource/TwoStars", "TWO", 24, 24), 'SAMPLE',
If(TEXT( Ratings__c )= '3' , IMAGE("/resource/ThreeStar", "THREE", 24, 24), 'SAMPLE',
If(TEXT( Ratings__c )= '4' , IMAGE("/resource/FourStar", "FOUR", 24, 24), 'SAMPLE',
If(TEXT( Ratings__c )= '5' , IMAGE("/resource/FiveStar", "FIVE", 24, 24), 'SAMPLE')))
))
but getting error as " Error: Incorrect number of parameters for function 'If()'. Expected 3, received 4" but if I make it three then it is showing one pparameter is missing.

Thanks,
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Mokshada,

There was syntax error in If() statemnets. Can you try below.
 
If(TEXT( Ratings__c )= '1' , IMAGE("/resource/OneStar", "ONE", 24, 24), 
If(TEXT( Ratings__c )= '2' , IMAGE("/resource/TwoStars", "TWO", 24, 24), 
If(TEXT( Ratings__c )= '3' , IMAGE("/resource/ThreeStar", "THREE", 24, 24), 
If(TEXT( Ratings__c )= '4' , IMAGE("/resource/FourStar", "FOUR", 24, 24), 
If(TEXT( Ratings__c )= '5' , IMAGE("/resource/FiveStar", "FIVE", 24, 24), 'SAMPLE')))
))

If this solution helps, Please mark it as best answer.

Thanks,
This was selected as the best answer