8 Replies Latest reply on May 8, 2016 9:30 AM by Mahfooj Khan

# Can I do calculations in the tooltips text box?

Hi all,

What I wanted to do seems really simple. But I am having a hard time accomplish it in Tableau. For illustrative purpose, let's say I have a file with only 1 row of data. It only has four columns as the following:

 Course Name Male Female Total Tableau 101 20 30 50

Now, I created a very simple bar chart by using Measure Name and Measure Value (Male and Female) to show how many students that I have in each gender. When I hover over to each bar, I am able to see the raw number of students. But besides that, I always wanted to show percentages (40% male, 60% female). How could I edit the tooltips to do this? (when hover over to the male bar, it will show 20 and 40%)

I was trying to do [Measure Value]/[Total] in the tooltips edit window, but it showed the formula in a text way (20/50) instead of the result of the calculation. I also thought about using calculated field, but it seems like [Measure Value] can not be used in the calculated field.

I know I can go back to the source file and transpose the data outside of Tableau, but is there any way that I could accomplish this in Tableau??

Thanks,

Bingcan

• ###### 1. Re: Can I do calculations in the tooltips text box?

Hi Bingchan,

From my point of view the data to be remodified as per my sample data.

Find the attachment of my workbook and get back to me if it's solved your problem.

• ###### 2. Re: Can I do calculations in the tooltips text box?

Hi Bingcan,

Now drag the Male percentage calculation in male bar tool tip

and Female percentage calculation in female bar tool tip

Now you can see your desired output.

Please find attached workbook for the same. I am using Tableau 9.3

• ###### 3. Re: Can I do calculations in the tooltips text box?

Hi Akram,

Thanks for you response.

This is what I wanted to show in the tooltip, but I saw you transposed the data from one row to two rows, and had Male and Female as two values of the gender dimension.  Do you think if there is any way to achieve this without transposing the underlying data? The reason that I am asking for this is because my real work is based on a direct data feed from the live database, transposing the data outside of Tableau would require adding one more step in the process which I am trying to avoid here.

Thanks,

Bingcan

• ###### 4. Re: Can I do calculations in the tooltips text box?

Thanks Rohan for the response.

You way of doing this is essentially creating two charts - one for male and one for female. Do you think if there is a way to collapse the two charts together into one chart, and align the bars for male and female side by side like below? and when you hover to Female bar, it shows 60%, and Male bar shows 40%? (again, the data file only has one row here for Tableau 101 only)

I am not trying to create more road blocks there. It's just in my real work , I have way more columns ("sales for product 1", "sales for product 2"..."sales for product 25" and a "total sale" column in one row). It's going to be very hard for the end user to read if I align them horizontally like what you did for 25 different products.

Thanks,

Bingcan

• ###### 5. Re: Can I do calculations in the tooltips text box?

try this.

-Rohan Malusare.

• ###### 6. Re: Can I do calculations in the tooltips text box?

Hi,

How about this? You can achieve this using dual axis. The way you wanted when you hover over any gender it should show only % of that particular gender.

Let me know if you've any query.

Mahfooj

• ###### 7. Re: Can I do calculations in the tooltips text box?

This is great. Thanks Mahfooj.

It worked really good for two measures. Do you know if I can add more measures to the dual axis? I tried but it looked really weird, and also it looks like the "synchronize" function is going away with more than 2 axes to synchronize...

• ###### 8. Re: Can I do calculations in the tooltips text box?

Only 2 axes can be superimposed. You can try Dual Axis Measure Values with Measure Values. As you have most likely figured out, removing fields from the Measure Values shelf for 1 of the axes removes it for both.

In addition, you cannot blend Measure Values from a secondary data-source, so that rules out this approach as well. One approach that succeeds in adding another measure is to add the measure in question to your detail shelf, and add a reference line. Obviously this isn't the most aesthetically pleasing option, but if your view is the one in question, I don't think it would affect things much. This is the only option of which I am aware.

This is generally where I would encourage someone to rethink how they are visualizing something and what they are trying to display.