Create Filtered Line Chart with Tableau Public

One of the advantages of interactive visualizations over static (including printed) is the ability to store a lot more data, and show it only when required. In other words, an interactive visualization can be made into a data-exploration tool that won’t overwhelm the viewer at first sight, but will allow the viewer to “dig” and find specific data points and patterns.

In this tutorial, we will build an interactive filtered line chart with Tableau Public like is shown in Figure 5.40. The filter will be a collection of checkboxes that allow to add/remove lines from the chart. Viewers can hover over each line to identify the school name and data attached to it.

We will use % Population with Internet Access by the World Bank. You can download the dataset here.

Figure 5.40: Internet Access by Country, 1995–2018.

We assume that you have Tableau installed. If not, see the previous tutorial, Create XY Scatter Chart with Tableau Public.

Connect Text File and Build a Line Chart

Open Tableau Public, and under Connect menu, choose Text file. Tableau may or may not have imported the table automatically. If you see the preview of the table with three columns: Country Name, Year, and Percent Internet Users, you can proceed to Sheet 1.

If not, drag and drop the file (under Files section in the left) to the Drag tables here area. Once you see the preview, go to Sheet 1.

Your variables will be listed under Tables in the left-hand side. The original variables are displayed in normal font, the generated variables will be shown in italics (such as Latitude and Longitude that Tableau guessed from the country names).

To build a line chart,

  1. Drag Year variable to Columns.
  2. Drag Percent Internet Users variable to Rows. The variable will change to SUM(Percent Internet Users). You should see a single line chart that sums up percentages for each year. That is completely incorrect, so let’s fix it.
  3. In order to “break” aggregation, drag and drop Country Name to the Color box of the Marks card. Tableau will warn you that the recommended number of colors should not exceed 20. Since we will be adding filtering, we don’t care about it much. So go ahead and press Add all members button.
  4. Now you should see an absolute spaghetti plate of lines and colors. To add filtering, drag Country Name to the Filters card. In the Filter window, make sure all countries are checked, and click OK.
  5. Right-click on Country Name pill in Filters card, and check Show Filter (see Figure 5.41)
  6. You will see a list of options with all checkboxes on have appeared to the right of the visualization. Click (All) to add/remove all options, and add a few of your favorite countries to see how the interactive filtering works.
After you drag Country Name to the Filters card, make sure the Filter is displayed.

Figure 5.41: After you drag Country Name to the Filters card, make sure the Filter is displayed.

Add Title and Caption, and Publish

Replace Sheet 1 title (above the chart) with “Internet Access by Country, 1995–2018” by double-clicking on it. In the menu, go to Worksheet > Show Caption to add a Caption block under the chart. Use this space to add source of your data (World Bank), and perhaps credit yourself as the author of this visualization.

Change Standard to Fit Width in the dropdown above the Columns field.

You may notice that the x-axis (Year) starts with 1994 and ends with 2020, although our data is for 1995–2018. Double-click on the x-axis, and change Range from Automatic to Fixed, with the Fixed start of 1995, and the Fixed end of 2018. Close the window and see that the empty space on the edges has disappeared.

Once your filtered line chart looks like the one shown in Figure 5.42, you are ready to publish.

This workbook is ready to be published.

Figure 5.42: This workbook is ready to be published.

To publish the filtered line chart to the web, go to File > Save to Tableau Public As…. You may be prompted with the window to log in to your account (or create one if you don’t have it yet). The next steps are fairly self-explanatory, and you can consult the previous tutorial for more information on publishing.

See the Embed Tableau Public on Your Website section of this book to insert the interactive version of your chart on a web page that you control.


Congratulations on creating interactive charts that pull readers deeper into your story, and encourage them to explore the underlying data! As you continue to create more, always match the chart type to your data format and the story you wish to emphasize. Also, design your charts based on the principles and aesthetic guidelines in this chapter. While anyone can click a few buttons to quickly create a chart nowadays, your audiences will greatly appreciate well-designed charts that thoughtfully call their attention to meaningful patterns in the data.

The next chapter on Map Your Data follows a similar format to introduce different map types, design principles, and hands-on tutorials to create interactive visualizations with spatial data. Later you’ll learn how to embed interactive charts on your web in chapter 7.

To learn about more powerful charting tools, see Chart.js and Highcharts templates in chapter 9, which give you ever more control over how your design and display your data, but also require learning how to edit and host code templates with GitHub in chapter 8.