Data Visualization Just Got Sweeter
When creating data visualizations in Tableau, twenty-four different charts, graphs, tables, plots and maps are provided to help you see and understand your data. One of those visualizations is a bar chart. Bar charts are one of the most common ways to visualize data because the end user can quickly compare trends across different categories. Bar charts are great, don’t get me wrong, but sometimes they can use a little “eye candy” to help them (lolli)pop. That’s right. I went there.
Here are the step-by-step directions to create a lollipop chart and then I’ll show you another neat trick which is how to filter the bar chart using parameter controls. I will be working in tableau 9.0 using the data source “Sample- Superstore” provided in tableau.
- For our example, let’s look at Sales broken down by Region in our data source. First, let’s drag sales into the rows and Region into the columns.
- Now we have our basic bar chart showing the Sales for each Region. Now lets get to making our lollipop chart by creating a dual axis. Hold down the Control key on your keyboard and click and drag the sum of sales in your rows to the right and unclick so that it looks like this:
- Now right click on the second sum of sales and click on dual axis and then right click on it again and unselect “show header”.
- You see that in the Marks card we have three options now: All, Sum(Sales), and Sum(Sales) (2). To make the stick of the lollipop lets change the Sum(Sales) mark type to bar and click size button and move the slider all the way to the left to make it as thin as possible.
- Then move to the Sum(Sales) (2) card and change the mark type to circle, click on the label button, click “show mark labels” and then change the label appearance alignment of vertical to “middle”.
- Then click on the size button and drag the slider to the next tick mark on the right so that the label is inside the circle shape.
- Now we have our basic lollipop chart. We can go ahead and drag reigon into the “All” Marks card and drop it into color to get this:
Pretty cool huh? But what if we wanted to see the sales for states within these regions filtered by the top number of states? No problem. Let me introduce you to a good friend of mine: Parameters. Using parameters in tableau is useful because is gives you a way to dynamically modify values in views. In instead of setting a filter manually and statically behind the scenes, parameters allow the end user to easily change the number of top subcategories within a category.
- First let’s change the angle at which we view these data by clicking the swap button on the top toolbar or by pressing Ctrl+ W. then drag the “State” demension right next to Region in your Rows.
- Now let’s create the parameter. Move your mouse down to the Parameters section in the data pane and right click in the white space below the two parameters and select “Create Parameter”. Change the settings as below:
- Right click on your newly made parameter and select “show parameter control”. Now you have the controls to the side of the visualization; however, there are two more steps we need to do in order for this control to work: 1) we need to create two calculated fields and 2) use them within the visualization.
- To create a calculated field, click Analysis, then “Create Calculated Field”. Name the first calculated field “Rank” and type in “INDEX()” in the text field below. Click OK.
- Create another calculated field, name this one Filter on Top States and enter “[Rank]<=[Top States]”. Click OK.
- Now let’s convert “Rank” to discrete by right clicking on “Rank” and selecting “Convert to Discrete” and drag Rank and drop it in between Region and State in the Rows.
- Right click on “Rank” in the Rows and click “Edit Table Calculation”
- In compute using, select “Advanced” and set up the calculation as follows:
- Then set up the calculation definition at the level of State and restarting every Region. Click OK.
- The last step is to drag and drop “Filter on Top States” in to the Filter Card and select “True”. Click OK.
Feel free to play around with other settings as well to make your chart as sweet as it can be.
As always, if you have any questions about this tutorial or Tableau, reach out to our consultant Matt Winter: firstname.lastname@example.org
About Matthew: Matthew leverages Business Intelligence tools with his background in Educational Measurement to empower businesses to make data-driven decisions. Recently, his work has been focused in the banking industry analyzing, interpreting, visualizing, and presenting workforce data from over 8,000 employee assessments.
Matthew received a B.A. in Chinese language and literature from California State University Los Angeles, an M.A. in Chinese language pedagogy from Indiana University, and an Ed.M. in Applied Linguistics, Second Language Assessment tract, from Columbia University, Teachers College. Matthew is certified as a Desktop 9 Qualified Associate in Tableau.