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
VDubVDub 

Color Coding Percent Change of Sales Formula

Hi,

I'm trying to color code my formula for percent change of YTD vs LYTD sales.  If the percent change is negative it make it red and if it's positive make it green.  I've been trying the stop lights but I would have to make another custom field instead of  changing the color of the value.  Is there anyway to do this?

Thanks, Vanessa 
CheyneCheyne
If I understand correctly, you're trying to create a field that will display a red image if the percent change is negative and a green image if the percent change is positive. In that case, I believe this should do the following:

IF((YTD_Sales__c - LYTD_Sales__c)/LYTD_Sales__c < 0, IMAGE("your_red_image_url"), IMAGE("your_green_image_url"))

That will display the green image if the percent change is 0. If you want to handle 0 percent change differently, you could do something like this:

IF((YTD_Sales__c - LYTD_Sales__c)/LYTD_Sales__c < 0, IMAGE("your_red_image_url"), IF((YTD_Sales__c - LYTD_Sales__c) /LYTD_Sales__c > 0, IMAGE("your_green_image_url"), IMAGE("your_zero_change_image_url")))
VDubVDub
Hi Cheyne,

I don't want to insert an image I want to actually change the color of the value returned by the formula to red or green based on if it's negative or positive.  See below.  Is there anyway to do that?

User-added image
CheyneCheyne
To my knowledge, there is no way to do this with a formula field. You could prepend the percent change value to an image, so that the actual value would display along with a green or red image. You would do that like so:

YTD_Sales__c - LYTD_Sales__c)/LYTD_Sales__c + IF((YTD_Sales__c - LYTD_Sales__c)/LYTD_Sales__c < 0, IMAGE("your_red_image_url"), IF((YTD_Sales__c - LYTD_Sales__c) /LYTD_Sales__c > 0, IMAGE("your_green_image_url"), IMAGE("your_zero_change_image_url")))