Connecting to data in a file Exercise 1
Last updated
Last updated
Follow this example to see a connection to an Excel file:
Navigate to the Connect to Excel sheet in the Chapter 02 Starter.twbx
workbook.
From the menu, select Data | New Data Source and select Microsoft Excel from the list of possible connections.
In the open dialog, open the Superstore.xlsx
file from the \Learning Tableau\Chapter 02
directory. Tableau will open the Data Source screen. You should see the two sheets of the Excel document listed on the left.
Double-click the Orders sheet and then the Returns sheet. Tableau will prompt you with an Edit Relationship dialog. For now, accept the defaults by closing the dialog.
Your Data Source screen should look similar to the following screenshot:
Figure 2.8: The Data Source screen with two objects (Orders and Returns)
Take some time to familiarize yourself with the Data Source screen interface, which has the following features (numbered in the preceding screenshot):
Toolbar: The toolbar has a few familiar controls, including undo, redo, and save. It also includes the option to refresh the current data source.
Connections: All the connections in the current data source. Click Add to add a new connection to the current data source. This allows you to join data across different connection types. Each connection will be color-coded so that you can distinguish what data is coming from which connection.
Sheets (or Tables): This lists all the tables of data available for a given connection. This includes sheets, sub-tables, and named ranges for Excel; tables, views, and stored procedures for relational databases; and other connection-dependent options, such as New Union or Custom SQL.
Data source name: This is the name of the currently selected data source. You may select a different data source using the drop-down arrow next to the database icon. You may click the name of the data source to edit it.
Object/data model canvas: Drop sheets and tables from the left into this area to make them part of the connection. You may add additional tables by dragging and dropping or double-clicking them. Each will be added as an object to the object model. You may also add tables as unions or double-click an object to edit the underlying tables and joins. For now, simply note that Orders and Returns are related together by the order ID.
Live or Extract options: For many data sources, you may choose whether you would like to have a live connection or an extracted connection.
We’ll look at these in further detail in the Working with extracts instead of live connections section later in this chapter.
Data source Filters: You may add filters to the data source. These will be applied at the data source level, and thus to all views of the data using this data source in the workbook.
Object Dropdown: Here you can select from a list of objects that are present in your data connection, including individual tables and relationships. Based on your selections, you may see or even modify certain aspects of the object. Here for example, the relationship between Orders and Returns has been selected. This reveals some options beneath that allow you to define the relationship.
Preview pane/metadata view: Depending on your selection in the options, this space displays either a preview of data or a list of all fields with additional metadata. Notice that these views give you a wide array of options, such as changing data types, hiding or renaming fields, and applying various data transformation functions. We’ll consider some of these options in this and later chapters.
Preview pane options: These options allow you to specify whether you’d like to see a preview of the data or a list of metadata, and how you would like to preview the data (examples include alias values, hidden fields shown, and how many rows you’d like to preview).
Conclude this exercise with the following steps:
Click the data source name to edit the text and rename the data source to Orders and Returns
.
Navigate to the Connect to Excel sheet and, using the Orders and Returns
data source, create a time series showing a Count of Returns by Return Reason. Your view should look like the following screenshot:
Figure 2.9: The number of returns by return reason