Friday, March 8, 2013

[TABLEAU] Creating A Grouped Bar Chart


             Creating a Grouped Bar Chart

A grouped bar chart shows comparisons vividly and in a way that can be taken in at a glance. 

For this example, connect to the Superstore sample.


Create a calculated field

A calculated field provides the environment you need to create this view. For a grouped bar chart, you need a continuous field that anchors the horizontal location of each bar, forming the group. For this example, you create a calculated field called Region Position. Its formula is as follows:

CASE [Region]
WHEN "Central" THEN 2
WHEN "East" THEN 2.5
WHEN "South" THEN 3
WHEN "West" THEN 3.5
ELSE 4
END


Step 1
Select Analysis > Create Calculated Field.


Step 2
In the Calculated Field dialog box, make the following selections:

  1. In the Name text box, type Region Position.
  2. Press the Tab key to move the cursor to the Formula text box.
  3. In the Functions list, double-click CASE.
  4. In the Fields list, double-click Region.
  5. Space, and then type WHEN "Central" THEN 2 WHEN "East" THEN 2.5 WHEN "South" THEN 3 WHEN "West" THEN 3.5 ELSE 4 END.





Step 3
When finished, click OK.


Set up the view

Step 1
From the Dimensions pane, drag Category to the Columns shelf.


Step 2
In the Measures pane, right-click Region Position and select Convert to Dimension.




Step 3
In the Dimensions pane, right-click Region Position again, and select Convert to Continuous.





Step 4
From the Dimensions pane, drag Region Position to the Columns shelf.


Step 5
From the Measures pane, drag Sales to the Rows shelf.


Step 6
On the Marks card, in the list, select Bar.


Step 7
From the Dimensions pane, drag Region onto the Color shelf on the Marks card.



Step 8
On the Marks card under Size, drag the slider all the way to the right to widen the bars.


Step 9
Right-click the X axis and select Edit Axis.


Step 10
In the Edit Axis dialog box, under Range, select Fixed.


Step 11
In the Start text box, change the setting to 1, and in the End text box, change the setting to 4.5.






Step 12
When finished, click OK.


Step 13
Drag the right edge of the view to the left to move the bars together.


Step 14
Right-click the X axis and clear the selection of Show Header.









2 comments:

  1. Very neat method. However, I have a question about my own student course data. For each course, I have two bars need to be displayed side by side: enrolled and passed, both are calculated field. How to group two calculated field? They show as "Measured Names", however in the calculation of "barposition" I cannot use "CASE [Measure Names]". I also tried to create a parameter, then a new calculation:
    CASE [ForPosition]
    WHEN "Enrolled" THEN 2
    WHEN "Pass Counts" THEN 3
    ELSE 4
    END, and following your method, they still only show as stack bar on top of each other, not side by side. Any suggestion? Thanks!

    ReplyDelete
  2. Thank you for your guide to with upgrade information.
    Tableau Online Course

    ReplyDelete