Search code examples
tooltiptableau-api

Tableau map tooltip not displaying average reference line


I created a chart visualising the cost of living in different cities and entered a line indicating the average. When integrating this sheet into the tooltip of my map, the line is not representing the average anymore but the actual cost of living for each city. I have been trying a lot but can't seem to figure it out. Thankful for any tip!

Screenshot 1: chart, Screenshot 2: map Screenshot 3: customisations for editing reference line


Solution

  • That's because the tooltip, triggered by the click/hover, is taking into consideration just a city at once, and so the average value is equal to the sum of that specific city: you're running average on just one city.

    In order to compute the correct reference value you should create a calculated field like this using LOD:

    { FIXED : SUM([Cost Of Living])} / { FIXED : COUNTD([City])}
    

    Then you could use that calculated field in a dual axis chart.

    Doing so, since EXCLUDE acts before dimension filters, you will be able to preserve your average across City even though tooltip will trigger a filter.

    Take a look at this simple example made with superstore and keep and eye on the red line (LOD v2) which relates to the calulated field above.

    enter image description here

    As you can see there's also a blue line which relates to the previous calculated field I wrote (LOD v1):

    { EXCLUDE [State] : AVG(  { FIXED [State] : SUM([Sales])})}
    

    Once we move to our main worksheet triggering the viz in tooltip, you'll see that the red value still keep the correct value calculated on all data, while the blue value is taking into consideration just data according to filter.

    enter image description here

    In fact FIXED is the only LOD calculus which act before the dimension filters and it's able to bypass the filtering triggered by the tooltip.