You're right, Tableau needs a measure (specifically a continuous variable that creates an axis) to display a reference line. Since bins are discrete variables that create headers, you'd need to use annotations. However, annotations are limited in what values they can display since it's not clear to Tableau what should be included in the calculations. My suggestion is to create the calculated fields for the means and medians and put those in a separate worksheet, then manually enter the values into the annotations on the histogram. I used two annotations to duplicate your image get the vertical line and line with arrow in the attached workbook.
Hi Jonathan, thanks for your reply ! That's how I managed to do it indeed.
2 of 2 people found this helpful
Another option is to not use Tableau's provided bin field type, and instead use a calculated field like:
for a bin size of 100
you can then use some custom table calculation fields to get your reference lines on the continuous axis, as in the attached.
This was a duplicate post, I am looking forward to the new forum.
Thanks for the alternative, Joe!
Thank you Joe, it will be very useful !
Jonathan, Joe, it looks like my version of Tableau (v 7.0) do not accept MEDIAN function in calculated fields.
It also looks like it is not listed in the official function list (http://onlinehelp.tableausoftware.com/v7.0/pro/online/fr-fr/functions.html).
Have you met this case before ?
I've run into this before. If your data source is Access or Excel, the MEDIAN function is not available, unless you create an extract. The reason for this is that the Microsoft JET engine doesn't support the median function, so you have to bring the data into Tableau and use Tableau's native function. (This might be true for certain other data sources as well). Another function that is not available in Access or Excel is COUNTD.
Awesome ! Thanks for your help !
I realise this is an old post, but your answer is exactly what I've been looking for. The only problem is I can't work out how to replicate it.
I've created the calculated field as described but when I add the equivalent of 'sales (continuous bin)' to columns it always comes up as sum(sales (continuous bin)).
Any idea what I'm doing wrong?
I found this old post quite helpful too. I think the last step that you are missing is to go to the Analysis menu and unselect the 'Aggregate Measures' option.
2 of 2 people found this helpful
This was something that was needed in a prior version, but is no longer needed. We can now configure Bin fields as continuous dimensions.
If you are curious about the expression, here is a breakdown of what happens if the value of [Sales] is 1234:
1. 1234/100 = 12.34
2. INT(12.34) = 12
3. 12*100 = 1200
4. 1234<0 = False
5. IIF(False,100,0) = 0
6. 1200-0 = 1200
This is doing the same thing as configuring a field as a Bin field. Back when I made this comment, a Bin field could only be a discrete dimension, and by calculating it manually, we could use it as a continuous dimension.
1 of 1 people found this helpful
>>>but is no longer needed. We can now configure Bin fields as continuous dimensions
While it is true that bins can be configured as continuous dimensions, there is still no option to add a vertical reference line, as far as I can see. It would seem that it is still necessary to use a calculated field for bins if you want a vertical reference line.. Am I missing something?