Connecting to data

Tableau connects to data stored in a wide variety of files and databases. This includes flat files, such as Excel documents, spatial files, and text files; relational databases, such as SQL Server and Oracle; cloud-based data sources, such as Snowflake and Amazon Redshift; and Online Analytical Processing (OLAP) data sources, such as Microsoft SQL Server Analysis Services. With very few exceptions, the process of analysis and creating visualizations will be the same, no matter what data source you use.

We'll cover data connections and related topics more extensively throughout the book. For example, we'll cover the following:

  • Connecting to a wide variety of different types of data sources in Chapter 2, Connecting to Data in Tableau.
  • Using joins, blends, and object model connections in Chapter 13, Understanding the Tableau Data Models, Joins, and Blends.
  • Understanding the data structures that work well and how to deal with messy data in Chapter 14, Structuring Messy Data to Work Well in Tableau.
  • Leveraging the power and flexibility of Tableau Prep to cleanse and shape data for deeper analysis in Chapter 15, Taming Data with Tableau Prep.

In this chapter, we'll connect to a text file derived from one of the sample datasets that ships with Tableau: Superstore.csv. Superstore is a fictional retail chain that sells various products to customers across the United States and the file contains a record for every line item of every order with details on the customer, location, item, sales amount, and revenue.

Please use the supplied Superstore.csv data file instead of the Tableau sample data, as there are differences that will change the results.

The Chapter 1 workbooks, included with the code files bundle, already have connections to the file; however, for this example, we'll walk through the steps of creating a connection in a new workbook:

  1. Open Tableau. You should see the home screen with a list of connection options on the left and, if applicable, thumbnail previews of recently edited workbooks in the center, along with sample workbooks at the bottom.
  2. Under Connect and To a File, click on Text File.
  3. In the Open dialog box, navigate to the \Learning Tableau\Chapter 01 directory and select the Superstore.csv file.

You will now see the data connection screen, which allows you to visually create connections to data sources. We'll examine the features of this screen in detail in the Connecting to data section of Chapter 2, Connecting to Data in Tableau. For now, Tableau has already added and given a preview of the file for the connection:

Figure 1.1: The data connection screen allows you to build a connection to your data

For this connection, no other configuration is required, so simply click on the Sheet 1 tab at the bottom to start visualizing the data! You should now see the main work area within Tableau, which looks like this:

Figure 1.2: Elements of Tableau's primary interface, numbered with descriptions below

We'll refer to elements of the interface throughout the book using specific terminology, so take a moment to familiarize yourself with the terms used for various components numbered in the preceding screenshot:

  1. The menu contains various menu items for performing a wide range of functions.
  2. The toolbar allows common functions such as undo, redo, save, add a data source, and so on.
  3. The Data pane is active when the Data tab is selected and lists all tables and fields of the selected data source. The Analytics pane is active when the Analytics tab is selected and gives options for supplementing visualizations with visual analytics.
  4. Various shelves such as Pages, Columns, Rows, and Filters serve as areas to drag and drop fields from the data pane. The Marks card contains additional shelves such as Color, Size, Text, Detail, and Tooltip. Tableau will visualize data based on the fields you drop onto the shelves.

    Data fields in the Data pane are available to add to a view. Fields that have been dropped onto a shelf are called in the view or active fields because they play an active role in the way Tableau draws the visualization.

  5. The canvas or view is where Tableau will draw the data visualization. In addition to dropping fields on shelves, you may also drop fields directly on to the view. A title is located at the top of the canvas. By default, the title displays the name of the sheet, but it can be edited or hidden.
  6. Show Me is a feature that allows you to quickly iterate through various types of visualizations based on data fields of interest. We'll look at Show Me toward the end of the chapter.
  7. The tabs at the bottom of the window give you options for editing the data source, as well as navigating between and adding any number of sheets, dashboards, or stories. Often, any tab (whether it is a sheet, a dashboard, or a story) is referred to generically as a sheet.

A Tableau workbook is a collection of data sources, sheets, dashboards, and stories. All of this is saved as a single Tableau workbook file (.twb or .twbx). A workbook is organized into a collection of tabs of various types:

  • A sheet is a single data visualization, such as a bar chart or a line graph. Since sheet is also a generic term for any tab, we'll often refer to a sheet as a view because it is a single view of the data.
  • A dashboard is a presentation of any number of related views and other elements (such as text or images) arranged together as a cohesive whole to communicate a message to an audience. Dashboards are often designed to be interactive.
  • A story is a collection of dashboards or single views that have been arranged to communicate a narrative from the data. Stories may also be interactive.

Along the bottom of the screen, you'll notice a few other items. As you work, a status bar at the bottom left will display important information and details about the view, selections, and the user. Various controls at the bottom right allow you to navigate between sheets, dashboards, and stories, as well as to view the tabs with Show Filmstrip or switch to a sheet sorter showing an interactive thumbnail of all sheets in the workbook.

Now that you have connected to the data in the text file, we'll explore some examples that lay the foundation for data visualization and then move on to building some foundational visualization types. To prepare for this, please do the following:

  1. From the menu, select File | Exit.
  2. When prompted to save changes, select No.
  3. From the \learning Tableau\Chapter 01 directory, open the file Chapter 01 Starter.twbx. This file contains a connection to the Superstore data file and is designed to help you walk through the examples in this chapter.

The files for each chapter include a Starter workbook that allows you to work through the examples given in this book. If, at any time, you'd like to see the completed examples, open the Complete workbook for the chapter.

Having made a connection to the data, you are ready to start visualizing and analyzing it. As you begin to do so, you will take on the role of an analyst at the retail chain. You'll ask questions of the data, build visualizations to answer those questions, and ultimately design a dashboard to share the results. Let's start by laying some foundations for understanding how Tableau visualizes data.