Edit – This post describes one approach. But, it turns out, there is an easier way: Dynamic Annotations (Part 3)
Part 1 described how to implement dynamic annotations in Tableau using a copy of a measure as a dual axis. However, there were some limitations to that approach. The biggest limitation is that you won’t be able to use the dual axis for anything else.
Here is a dashboard with a dual axis combo chart view that makes use of dynamic annotations.
This solution is very similar to the one proposed in Part 1. However, instead of using a dual axis, I’m using the Measure Names / Measure Values. With this approach, I can have as many copies of the measure for the marks I want to annotate as I want. In that way, I can have multiple “sets” of annotations.
Here are the steps:
- Create a parameter to control which set of annotations is shown.
Tip: Use an integer type for performance and ease of coding. You can change the “Display As” value for user-friendliness.
- For every field that will define a mark for which you will use dynamic annotations, create a calculated copy. Create a copy for each “set” of annotations. Here is an example of the calculated copies of the Sales measure. Note that the field only has a value when the corresponding parameter is selected. Otherwise it evaluates to NULL.
|Sales (Annotation Set 1)||IF [Annotation] = 1 THEN [Sales] END|
|Sales (Annotation Set 2)||IF [Annotation] = 2 THEN [Sales] END|
|Sales (Annotation Set 3)||IF [Annotation] = 3 THEN [Sales] END|
|Sales (Annotation Set 4)||IF [Annotation] = 4 THEN [Sales] END|
- Once you have a view using the original field to define the marks as you want, replace that field with the [Measure Values] field. Then make sure each calculated copy is placed on the Measure Values shelf.
Tip: You will need to add [Measure Names] to the Level of Detail if you want to connect a line.
- Cycle through selecting each parameter value. Add mark annotations as desired for each parameter selection.
That’s it! You now have annotations that dynamically change based on end-user interaction!