12 Replies Latest reply on Feb 11, 2019 10:59 AM by Ji Zhou

# create vertical reference line in histogram, x-axis from 0 to 1

Hi Tableau experts,

I have faculty evaluation data for several depts, scores ranging from 0 to 1. I created a histogram showing the score distribution per dept, using standard bin sizes of 0.1. I want to add vertical reference lines showing the average score for each dept and for the entire university, similar to what Joe Mako did in this post Reference line over a distribution graph and doing that for every dept and the university in my case.

It seems that to add a vertical reference line, a continuous bin x-axis need to be created. But I can't figure out how to create a continuous x-axis from 0 to 1 in my case. Changing the Score (bins) on the rows from discrete to continuous would create the continuous x-axis. But I still can't add the vertical line. Maybe some table calculation is needed to create the continuous bins? Could anyone please help me? Thanks.

I attached a sample workbook. The sheet "reference points" are the numbers I want to draw on the histogram.

Best,

Ji

• ###### 1. Re: create vertical reference line in histogram, x-axis from 0 to 1

Please click on the Score (bin) as shown and you can change it to continuous.

• ###### 2. Re: create vertical reference line in histogram, x-axis from 0 to 1

Hi Hari, thanks for taking a look. I changed it to continuous, but still wasn't able to add the vertical line. Could you please add how to add the reference line? Thanks a lot!

• ###### 3. Re: create vertical reference line in histogram, x-axis from 0 to 1

Hi

Ok here are 2 options the first creates a line graph based on the values in your table

The second goes into your histogram and puts a department average and university average on each of the department histograms _ the lines are very close together

each chart is created by first placing the appropriate measure on the detail tile of the marks card and then going to the analytics tab and dragging the reference line to the chart

Select the PANE option -

When the window opens go to the drop down in the center and select the appropriate measure

Let me know if this helps

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

• ###### 4. Re: create vertical reference line in histogram, x-axis from 0 to 1

Hi Jim,

Thanks for taking a look. In my case, adding a vertical line for each dept and the whole university would be more desirable. The x-axis shows the score, and the y-axis shows the frequency/percentage distribution. So adding vertical lines would make more sense.

Please share if you know how to do that. Thank you!

Best,

Ji

• ###### 5. Re: create vertical reference line in histogram, x-axis from 0 to 1

the workbook is attached

you create a dual axis chart - one for the dept ave and one for the university ave. then make the vis a line viz and you are there

Let me know if this helps

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

1 of 1 people found this helpful
• ###### 6. Re: create vertical reference line in histogram, x-axis from 0 to 1

Hi Jim,

Sorry I meant adding vertical lines to the histogram, like the what Joe Mako did in this post: Reference line over a distribution graph.

Please take a look when you get a chance. Thanks a lot!

Ji

• ###### 7. Re: create vertical reference line in histogram, x-axis from 0 to 1

Unfortunately, you cannot create reference lines when you are working with bins. So, if there is anyway that you can achieve the bin functionality using a calculated field, then you can create the reference line as required.

1 of 1 people found this helpful
• ###### 8. Re: create vertical reference line in histogram, x-axis from 0 to 1

Yes, that's what I read. I need to create continuous bins by a table calculation. But I can't figure out how to do that...

• ###### 9. Re: create vertical reference line in histogram, x-axis from 0 to 1

Hi

Creating the continuous vertical bins is a straight forward calculation where you just count the records that will fall into .1 increments (.1,.2,.3 etc) and use the new calculation as a continuous field on the rows shelf - now that said - i did that but still could not get a vertical line

Good luck

Jim

• ###### 10. Re: create vertical reference line in histogram, x-axis from 0 to 1

Thank you Jim. I will keep working on this and will report back if I find a way...

• ###### 11. Re: create vertical reference line in histogram, x-axis from 0 to 1

Not sure if you ever found a solution to this, but I think I may have found it after searching many of the posts on this forum and finding them wholly unsatisfactory. To add a vertical line first create a custom bin from a calculated field (Use Round with -1 instead of the very confusing calc in the original workbook). Using a bin created by Tableau becomes a Dimension, which won't work, so this is why we have to create a measure first. Put the measure onto the Columns shelf, right click and convert to Dimension.

Now put your measure on the Rows shelf. Both pills should be green. Right click the X axis and voila, "add reference line" should now be available. All that's left to do is to reference the calculated field that you want as your line to be in the window that pops up (the TOTAL(AVG([Profit])) field.

3 of 3 people found this helpful
• ###### 12. Re: create vertical reference line in histogram, x-axis from 0 to 1

Thank you Mark.