Here is an example of Star Rating field using Formula in Salesforce. In below example I’m displaying the Star Rating, based on a Student’s grade.
In Student custom object, I have created a Picklist Field.
Label: Grade
Type: Picklist
Values:
0 1 2 3 4 5
And then I have created a Formula Field on the same Student object. This is to represent the Star Rating.
Label: Rating
Type: Formula
Formula:
IMAGE( IF(TEXT(Grade__c) = '0', "/img/samples/stars_000.gif", IF(TEXT(Grade__c) = '1', "/img/samples/stars_100.gif", IF(TEXT(Grade__c) = '2', "/img/samples/stars_200.gif", IF(TEXT(Grade__c) = '3', "/img/samples/stars_300.gif", IF(TEXT(Grade__c) = '4', "/img/samples/stars_400.gif", IF(TEXT(Grade__c) = '5', "/img/samples/stars_500.gif", "/img/samples/stars_000.gif" )))))), 'Rating Level')