I'm having trouble seeing where I can have percentages display on a pie chart I created.
In a related question, can I get both company names and percentage labels visible on one pie chart? I have the percentages but want to add the company names too.
In this case you have to make a calculated field that includes the name of the company and the percentage. Then you could use that calculated field as a label.
Related to this last answer: as far as I understand, if I want to concatenate a company name and value, I need to transform the value into a string. Doing this returns a very long number format (e.g. 45.15484577755). Is there any way to keep the number format? Is the only way to do this to truncate the right side of the string? This can get complicated when you don't have a fixed number of digits before and after the decimal point, and if you want to include thousands delimiters.
A A., This would be another use case for FORMAT() function.
see http://www.tableausoftware.com/search/forum/FORMAT%28%29%20function for related discussions.
The link you provided does not seem to work for me either.
Update: Okay I found the link http://community.tableau.com/thread/109893. Thanks for the tip!
How do I do the calculated field with percentage in it?
ATTR([Company] ) + ": " + STR(INT(ROUND([Percentage of Volume]*100,0)))+"%"
However, the result of [Label} would always show the percentage values as 100% for each company.
Note that [Percentage of Volume] by itself when appearing in a table correctly showed the percentage.
I think it was because the scope of the TOTAL() aggregation function changed from covering all companies to covering only one company. However, how can I control the scope?
Update #1: I further played with the two calculated fields below. The difference between them is supposedly only a format change (from a number to a string with a % display). However, in the same table, the first calculated field showed the percentage correctly, the second one always showed 100%. What went wrong?
Update #2: Hi, apparently I cannot just copy and paste a formula to the "Formula" area of a "Calculated Field" dialog box. The path of how to get there is also important. Here is what I did to get it to work.
I placed the measure (e.g. [Volume (MB)] in a field (e.g.the "Measure Values" card). Only from here when I right clicked, I could see the "Quick table calculation" context menu.
I gave this calculation a new name (e.g. "Label: Company+Percentage").
I then step by step converted the formula to a string: first round() it, then apply str(), then pre-pend the string by [Company] + ": ", and finally append the string with+ "%".
When I went thru' the above procedure to create the above calculated field, the field show the correct percentage.
Hope this would help someone who read this.
Instead of getting in to the actual code just add 'Quick Table Calculation' to the label and select option'Percent of Total' that will give you the actual percentages. inside the Pie chart.