问题
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-
- Pivot the two fields in data tab of tableau itself
- 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.
- add calculated field using datepart('hour', [time]) then create bins of size = 1 from this field
- 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