Conditionally coloured tooltip text

by Paul Hunt

Imagine we’re looking at the profit of a company, say Superstore, across different states. Some states make profit and some make a loss, as illustrated in the chart below.

The bars representing each state are coloured gold if they make profit, and grey if they make a loss. We want to apply this same colour palette inside the tooltip to the profit amount.


Step 1

Create a new calculated field(s) with the condition(s) that should be met in order to turn the text a certain colour. In this example we want the colour gold to be applied when profit is positive (i.e. > 0) and the colour grey to be applied when profit is negative (i.e. < 0). So we create the following two calculated fields.


Step 2

We then drag these two fields onto the tooltip marks card.


Step 3

Then we click on the tooltip marks card which opens up a text window. We want to edit the existing non-conditional text, which looks like this


and replace <SUM(Profit)> with both of our newly created fields. We then colour each of these field names manually (highlight the field text).


Only one of the two fields’ conditions are met at any one time since they are mutually exclusive. This means that only the appropriate field will appear in the tooltip when hovering.


Nice.

Tue 21 May 2019

Wed 01 May 2019

Thu 25 Apr 2019