I am a regular participant (and more recently a coach) in the #WorkoutWednesday Tableau Community Project initiative (check out this link for more information). A recent challenge made use of annotations to ‘label’ a mark that had been selected. But that selected mark could change based on some interactivity, and I was unable to keep the annotation showing. I couldn’t find any other community blogs or knowledge articles to explain how to make it work, and ended up seeking the help from colleagues to get to the bottom of it.

Annotations vs Labels

Annotations in Tableau can be applied against a particular mark, a specific point, or an area on the canvas of your chart. Tableau’s own help documentation describes in detail what annotations are and how to use them, so I’m not going to go into detail on that in this post.

The primary difference between an annotation and a label is how they are displayed.

sales over time line chart in Tableau displaying an annotation against the December 2020 mark and a label against the November 2023 mark. 

In the image above, the annotation is against the December 2020 mark, and is enclosed within a white box with rounded edges and a border. An arrow points to the mark being annotated.

By contrast the label just shows text, and while this text can be formatted (colour, font, size, style etc changed), there is no ability to change the overall ‘look’ of the label.

Typical Annotation Behaviour

However, unlike labels, when applying annotations against a mark, they don’t display when another mark is selected. 

For example, in the image below, the mark for the customer, Dean percer, has been highlighted (in orange), and that mark has been annotated. The customer to highlight is based on the value in the pSelectedCustomer parameter. When that is changed to Ross Baird, the mark related to Ross is now highlighted in orange, but no annotations display at all; the annotation relating to Dean has disappeared, but no annotation is displayed for Ross. Changing the parameter back to Dean, and the annotation reappears.

 

Gif image showing how the annotation in Tableau displays against a highlighted mark, but disappears when a different mark is highlighted.

 

This behaviour may be desirable. Perhaps there is something specific about the mark relating to Dean that does need to be described differently or explicitly called out via an annotation, that is not necessary for any other marks.

But what if you do want the annotation to continue to display? Well you can achieve this using a reference to the parameter instead.

Displaying the annotation when the mark changes

Using the example above, on the marks card that represents the highlighted mark (in this instance the orange circle), replace the Customer Name field on the Detail shelf, with the pSelectedCustomer parameter, and ensure the annotation dialog references the <Parameters.pSelectedCustomer> variable instead.

Image indicates that the parameter should be added to the Detail shelf in Tableau and also referenced in the Edit Annotation dialog box.

Now when the parameter is changed from Dean percer to Ross Baird and to any other Customer Name, the annotation is retained.

Gif image showing how the annotation in Tableau displays against a highlighted mark, and is now retained when a different mark is highlighted.

A workbook to accompany this blog post containing some of the examples discussed, can be accessed from here.

Author
Donna Coles

Donna Coles

Tableau Visionary ¦ Data Junkie ¦ Run ¦ Zumba ¦ Footie Mum

Read more articles of this author
Let's discuss your data challenges

Join our community of data enthusiasts

Get industry insights, expert tips and Biztory news sent straight to your inbox with our monthly newsletter.