Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted

# 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
Sai Praveen (Salesforce Developers)

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')))
))```

Thanks,

Sai Praveen (Salesforce Developers)

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'
)```

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.

Thanks,

CharuDutt
Try Below Formula
```If Using Static Resource
IF(TEXT( Stage )= 'Prospect' , IMAGE("/resource/prospect", "ONE", 24, 24), 'SAMPLE'
)
```
Thank You!
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 Praveen (Salesforce Developers)

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')))
))```