You need to sign in to do that
Don't have an account?
Norm Gilbert
Display an Image with CASE() in Trailhead
I am stuck on the Challenge to Create a formula field that returns an image to indicate data quality. It's in the Text Formulas module of Advanced Formulas badge.
No matter what I try, I can't pass the Syntax checker. I am required to display a certain number of stars based on Data Quality calculated in another formula. And include alternate text. (By the way, is there any way to trace formulas, so I could see the number being returned by the data quality formula?)
Herer's my formula . . .
IMAGE
(CASE(Lead_Quality_Helper__c ,
5, ("/img/samples/stars_500.gif", "5 Stars",)
4, ("/img/samples/stars_400.gif", "4 Stars",)
3, ("/img/samples/stars_300.gif", "3 Stars",)
2, ("/img/samples/stars_200.gif", "2 Stars",)
1, ("/img/samples/stars_100.gif", "1 Stars",)
0, ("/img/samples/stars_000.gif", "0 Stars",)
"Unknown"))
IMAGE can take two parameters. The URL and the ALTERNATE TEXT. So I put both parameters surrounded by (.....). The Syntax checker says I am missing a parenthesis between the URL and the Alternate Text. But inserting one there results in an error that CASE is expecting a number, not text.
What am I doing wrong here?
No matter what I try, I can't pass the Syntax checker. I am required to display a certain number of stars based on Data Quality calculated in another formula. And include alternate text. (By the way, is there any way to trace formulas, so I could see the number being returned by the data quality formula?)
Herer's my formula . . .
IMAGE
(CASE(Lead_Quality_Helper__c ,
5, ("/img/samples/stars_500.gif", "5 Stars",)
4, ("/img/samples/stars_400.gif", "4 Stars",)
3, ("/img/samples/stars_300.gif", "3 Stars",)
2, ("/img/samples/stars_200.gif", "2 Stars",)
1, ("/img/samples/stars_100.gif", "1 Stars",)
0, ("/img/samples/stars_000.gif", "0 Stars",)
"Unknown"))
IMAGE can take two parameters. The URL and the ALTERNATE TEXT. So I put both parameters surrounded by (.....). The Syntax checker says I am missing a parenthesis between the URL and the Alternate Text. But inserting one there results in an error that CASE is expecting a number, not text.
What am I doing wrong here?
A helper formula is just a formula field that is referenced by another formula field. For instance, I create a Formula_A__c field that references Formula_B__c.
For an image formula, you'll create a formula field that's actually a Text type, and then in the formula editor, you'll use the IMAGE() formula to produce an image. The image formula is actually discussed in the description or scenario of the same Trailhead challenge you're working on.
I completed this challenge as below: Hope this helps.
Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Thanks,
Nagendra
IMAGE( CASE( Lead_Quality_Helper__c , 1, "/img/samples/stars_100.gif ", 2, "/img/samples/stars_200.gif", 3, "/img/samples/stars_300.gif", 4, "/img/samples/stars_400.gif", 5, "/img/samples/stars_500.gif", "else"), "Any Comment",height,width)
try this it works properly
Thanks,
Rahul Dey
Lead Quality Helper:
IF(ISBLANK(Email), 0, 1) + IF(ISBLANK(Phone), 0, 1) + IF(ISBLANK(Company), 0, 1) + IF(ISBLANK(Title), 0, 1) + IF(ISPICKVAL(Industry, ""), 0, 1)
Lead Quality:
CASE(Lead_Quality_Helper__c,
1, IMAGE("/img/samples/stars_100.gif", "one star"),
2, IMAGE("/img/samples/stars_200.gif", "two stars"),
3, IMAGE("/img/samples/stars_300.gif", "three Stars"),
4, IMAGE("/img/samples/stars_400.gif", "four Stars"),
5, IMAGE("/img/samples/stars_500.gif", "five Stars"),
IMAGE("/img/samples/stars_000.gif", "zero Stars"))
CASE(Lead_Quality_Helper__c,
1, IMAGE("/img/samples/stars_100.gif", "1 star"),
2, IMAGE("/img/samples/stars_200.gif", "2 stars"),
3, IMAGE("/img/samples/stars_300.gif", "3 Stars"),
4, IMAGE("/img/samples/stars_400.gif", "4 Stars"),
5, IMAGE("/img/samples/stars_500.gif", "5 Stars"),
IMAGE("/img/samples/stars_000.gif", "0 Stars"))