create side-by-side bar chart in Tableau

*爱你&永不变心* 提交于 2021-01-28 06:17:04

问题


I have 2 dimensions, “departure” & “arrival”. Both these dimensions are in DATETIME format. I want to display the number of records having departure & arrival for each hour (0 to 23hrs), as side-by-side bar chart.

I have tried different ways to create the visualization, but I can't figure out where I am going wrong. I have attached my Tableau file.

Sheet: Wrong_count_for_arrival --> If i choose, "Departure" in my Column field, The "departure" count is correct, however, "Arrival" count is wrong. And, if i choose, "Arrival" in my Column field, The "Arrival" count is correct, however, "Departure" count is wrong.

Sheet: double_values --> To correct above, if i put the "Departure" & "Arrival" in Columns field, then I am getting double values for both "departure" & "arrival" count.

I am trying to get visualization similar to "Wrong_count_for_arrival", but with correct count.

Attached is the Tableau workbook. Tableau workbook-sample data


回答1:


In your requirement arrival and departures are not related.
I achieved your desired view by doing these simple steps-

  1. Pivot the two fields in data tab of tableau itself
  2. let's say first field after pivot be 'arr or dep' which will be a dimension and another field be 'time' which will be date field.
  3. add calculated field using datepart('hour', [time]) then create bins of size = 1 from this field
  4. You'll get your desired view by adding hour_bins and 'arr or dep' to columns, sum(number of records) to rows and additionally arr_or_dep to color marks

Image preview



来源:https://stackoverflow.com/questions/63948953/create-side-by-side-bar-chart-in-tableau

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!