Color code bar based on date anchor

To highlight subset of bars in a bar chart, like the one below, requires the use of custom expressions and color assignments.

In this example, we have a date anchor that we want to highlight in red compared to the other bars. This builds upon an earlier post describing creating anchor and +/- N days - you can read more here:

Color shelf

The dashboard contains a date parameter that we are using in the color shelf expression. Using a conditional statement, we are forcing the color output to be one of two possible string values: “highlight” or “-”

if ([Order Date] = '<<dateparam>>', 'highlight', '-')

image

Color assignment

We then want to fix the assignment of these values to color within the Colors setting. Make sure to click on “Fix color for specified values”. That will provide a list of color - value mappings you can modify.

2 Likes