I was looking for a way to present more information in Tableau Tooltips and remembered seeing a way to include bar charts in Tooltips. I eventually found the article I remembered here but I found it rather fiddly to add the 100 character strings and also I ended up with many out of range results i.e. results that were either over 100 or minus values.
After a few attempts here is what I finally ended up with that seemed to give me what I was after:
And so it looks like in practice:
Here is what I did. First create the Profit Ratio of course:
Then we can use the SPACE and REPLACE functions of Tableau to create a string to the exact length of the calculated Profit Ratio.
First I need the Profit Ratio as number rather than Percentage rounded to 2 decimal places:
Then I can use this to fill a string with the appropriate number of spaces:
I can then replace the spaces with more useful characters. The extended ASCII character set is useful for this. To access this character set just hold down alt and type the number on the numeric keypad. You can find a list of the characters here. I will use the 219 character █.
Ok, now we have a dynamic length of bar but how to deal with positive or negative numbers.
I used two calculated fields for this. The one I created above named and modified like so:
This gives us our positive bars. For the negative I created the following:
I also used WINDOW_SUM to create the same but for the next row in order give some contrasting values for testing.
Now we have to values that are exclusive to each other, when one appears the other one doesn’t. Therefore we can use both in the tooltip with colour formatting to differentiate positive and negative like so:
Lösungen, die eine fundierte Entscheidungsfindung sicherstellen?
Informationen für Ihr Unternehmen, die qualitätsgesichert, entscheidungsrelevant sind und anspruchsvolle Geschäftsanalysen bieten? Gerne unterstützen wir Sie hierbei und stehen Ihnen für eine individuelle Fragen zur Seite. Tel.: +49 (0) 70 31 714-6215 oder per Kontaktformular