Number Sensitive Colors

Is it possible to tie colors to certain values? So if sales is below forecast, it's red, green if it's above, etc. 

Best Answer

  • zcameron
    zcameron admin
    Accepted Answer

    There are a number of ways to tie values in your data to colors on a visualization. Here are some examples:

     

    Sumo Card Conditional Formatting

    Sumo cards have conditional formatting built in. To access it,  hover over the field name of the field to which you want to apply conditional formatting and you'll see three dots become visible (in the table header not in the left nav). Click on the three dots and you will get a menu. From the menu, click on Conditional Formatting and a new menu will pop up which will allow you to enter your criteria and select the colors.1.png

    2.png

    3.png

     

     

    Gauge Card

    Gauge cards are a great way to visualize number ranges with colors. Simply use the range options under the chart properties to set up the ranges and colors you want to see. 

    Screen Shot 2016-03-08 at 10.11.16 AM.png

     

    Table Card Conditional Formatting

    You can also use HTML styles in a table card to change the way cells values are displayed. 

     

    The following Beast Mode examples will help you create conditional formatting on a standard (non-Sumo) table. 

     

    The formatting is accomplished by creating an HTML string which contains a DIV element where the background color changes based on user defined conditions. The three colors are "Domo" colors as well so it wil keep a consistent user experience.

     

    Green Background (#bbe491):

     

    CONCAT('<div style="background-color:#bbe491; width: 100%; height:100%; margin:-20px; padding:20px"><a href="#">', 'Green Conditional Format', '</a></div>')

     

    Yellow Background (#fccf84):

     

    CONCAT('<div style="background-color:#fccf84; width: 100%; height:100%; margin:-20px; padding:20px"><a href="#">', 'Yellow Conditional Format', '</a></div>')

     

    Red Background (#fcbcb7):

     

    CONCAT('<div style="background-color:#fcbcb7; width: 100%; height:100%; margin:-20px; padding:20px"><a href="#">', 'Red Conditional Format', '</a></div>')

     

    Note: The <a> element with a reference to # prevents the user from drilling on that column as it would create a filter for the full HTML string.

     

    Working Example:

     

    CASE

     

    WHEN `CHANGE` > 0 THEN CONCAT('<div style="background-color:#bbe491; width: 100%; height:100%; margin:-20px; padding:20px"><a href="#">', `CHANGE`, '</a></div>')

     

    WHEN IFNULL(`CHANGE`, 0) = 0 THEN CONCAT('<div style="background-color:#fccf84; width: 100%; height:100%; margin:-20px; padding:20px"><a href="#">', `CHANGE`, '</a></div>')

     

    WHEN `CHANGE` < 0 THEN CONCAT('<div style="background-color:#fcbcb7; width: 100%; height:100%; margin:-20px; padding:20px"><a href="#">', `CHANGE`, '</a></div>')

     

    END

     

     Note: Keep in mind that the value this Beast Mode returns is a STRING, any aggregations must be done w/in Beast Mode as aggregations will be disabled when building cards.

     

     

    I hope these examples can help you get started!

Answers

  • Would you be able to write comething similar to this in order to change the background color on a graph? I would love to be able to turn everything below my line green. It seems like there would be a way to do this by using pieces of this logic, but I can't figure it out in my trials. 

This discussion has been closed.