I think what you are asking for can be done with calculated fields. You can combine a dimension and a measure and add a line break with a calculated field like:
(notice that there is a line break in the quotes inside of the calculated field, that gives it a line break)
There are cases where you need multiple levels of aggregation, and therefor currently require custom SQL or pre-process to get the result sometimes.
Joe - interesting... this opens up some additional work, as the Dimension I would like to include is a group, which Tableau does not appear to like including in calculations. However, since the dimension is actually a numerical representation of a response value (e.g. 1 = good, 2 = very good, etc.) I think I can use the CASE function to test for the small set of possible values and return the appropriate text...
The chart that I am using is a stacked bar, where the current text field is a table calculation (Percent of Total within Cell), to give me for each row, the percent of the total for each bar.
Basically I am trying to represent for each row, the distribution of responses (totaling 10 to 100% for each row)
I am not sure how to replicate the % of row total calculation in the calculated field. I can get the # of records that fall into each response value using SUM([Number of Records])... but not sure what incantation of logic gives me something that represents the total number of records in that row to divide by to get the percent.
Make sense??? Any Hints???
Using the % of row will make this difficult. . . however what you could do is create a calculated field that is something like
when 1 then str(COUNT(RESPONSE)+" people answered Good")
when 2 . . . etc.
Then have a bar chart setup with Total Count on the vertical axis and [Response] on the horizontal (Might need to create a duplicate if it is a measure and change it to a dimension)
Then place your Calculated field in the text.
Then if you still want % Difference, just create a new table with it and put both on a Dashboard.
You guys post some interesting solutions. However to make it easier, quicker, and more flexible for a variety of chart types, I have another feature request / solution.
Here's what I'd like to do, simply. (Please let me know if there's a good workaround)
I'd like an option in the Mark Label formatting pane to be able to show both the percentage and the value. For example, I have a pie chart of information. My users said, "Well, this looks great. However I'd like to see both the percentage of the whole along with the actual number. Since this is in printed form, I can't hover over it..."
A simple option to show both would be a terrific start (maybe show one on top of the pie slices and one outside of them - allowing you to change the color for both for good contrast).
Oh and one more thing - similar to Excel, is there a way to have little pointer lines associate smaller slices with their numerical label?
I get an error: "Can't add a string and an integer"
Wrap the integer in STR([your int]) to convert it to a string.
Where [Sector] is a label and [RespondentID] is a unique numerical record identifier.
gets error: "Cannot mix Aggregated and non-aggregate arguments to function"
What I'm trying to accomplish is to get a text label on a pie chart to look like:
Brad - sorry I can't help, but can confirm that is the same errors I got when trying to accomplish this. I believe the problem stems from the fact that you are likely aggregating a field, therefore Tableau doesn't have a clear way to know which value of sector to assign to the result of the RespondentID count... To me it seem logical, in that if Sector was one of the dimensions, then as long as the data is aggregated by Sector, you would know which sector to apply, however I don't think Tableau has that kind of logic built into it today...
The issue is with the STR(COUNT(RespondentID) since Sector is not aggregated.
What you CAN do is change your formula to this
This way it tricks Tableau into seeing this as two aggregation functions.
What you'll need to do next though is throw Sector on the worksheet in front of your new calculated field and then hide it so it will give you all Sectors and their counts.
This worked for me perfectly! Thanks Jordan.