Chapter 123% of the exam45 min
Connecting to and Preparing Data
How Tableau Desktop connects to data with live connections or extracts, what .tds, .tdsx, .twb, .twbx and .hyper files hold, how to combine tables with relationships, joins and unions across one or more connections, and how to rename fields, alias values, assign geographic roles, change data types and set default properties.
By the end of this chapter you can
- Create a live connection and an extract, and explain the differences between them
- Save a data source's metadata in a .tds file, and build a data source that uses multiple connections
- Add relationships, joins and unions, and explain when to use a join versus a relationship
- Rename fields, alias values and assign geographic roles
- Change a field's data type and its default properties
Live connections and extracts
Scenario: A regional sales team keeps orders in a cloud database and targets in a spreadsheet. The analyst needs dashboards that are fast to use on a laptop on the road, and a weekly view that is always up to date.
You connect from the Connect pane on the start page: To a File (such as Microsoft Excel, text files, JSON or spatial files), To a Server (such as a database or cloud application) or Saved Data Sources. Tableau then opens the Data Source page, where you add tables to the canvas, preview the data and choose between a live connection and an extract. Live is selected by default.
| Live connection | Extract | |
|---|---|---|
| How it works | Sends queries straight to the data source every time the view changes | Copies the data into a snapshot that Tableau queries instead |
| Freshness | Always current | As current as the last refresh |
| Speed | Depends on the source system | Often faster, especially for slow or busy sources |
| Offline | Needs access to the source | Works without a connection to the source |
| File | None | A .hyper file (older versions used .tde) |
| Good for | Data that must be up to the minute, or a fast database | Performance, working offline, sharing a subset of data |
Creating an extract
- On the Data Source page, select Extract in the top-right corner. Select Edit to open the Extract Data dialog and choose options.
- Select a sheet tab. Tableau asks where to save the .hyper file and builds the extract.
- Save the workbook, so it keeps using the extract next time it opens.
You can also right-click the data source in the Data pane, or use the Data menu, and choose Extract Data.
The Extract Data dialog lets you make the extract smaller and faster:
- Data storage: logical tables (the default) or physical tables.
- Filters: keep only the rows you need, such as the last two years.
- Aggregation: aggregate data for visible dimensions, and roll up dates to a level such as month.
- Number of rows: all rows, a sample, or the top N rows.
- Hide All Unused Fields: hidden fields are left out of the extract.
Extracts are updated with a refresh. By default an extract is fully refreshed, replacing all the data. An incremental refresh adds only new rows, identified by a field such as a date or an ID that always increases. It needs all rows and isn't available when the extract is aggregated.
Exam tip: "Always shows the latest data" points to a live connection. "Faster, offline, or a smaller subset of the data" points to an extract. An extract is a snapshot: it changes only when it is refreshed.
Saving data sources and using multiple connections
What each file type holds
| File | What it contains |
|---|---|
| .twb | A workbook: its sheets, dashboards and stories and the connection information, but no data |
| .twbx | A packaged workbook: the workbook plus local files such as extracts, Excel and text files, and images |
| .tds | A data source: the connection information and metadata, such as default properties, calculated fields, groups, sets, bins and renamed fields, but no data |
| .tdsx | A packaged data source: the .tds plus local files, such as an extract or a text file |
| .hyper | An extract of the data |
Saving a data source as a .tds means you, and anyone you share it with, can reconnect with all your preparation work already done, instead of renaming fields and creating calculations again. To save one, right-click the data source's name at the top of the Data pane, choose Add to Saved Data Sources, and pick .tds or .tdsx. Saved in the Datasources folder of your Tableau repository, it appears under Saved Data Sources in the Connect pane.
Data sources with multiple connections
One data source can combine tables from different connections, such as an Excel file and a SQL Server database:
- On the Data Source page, select Add in the left pane and connect to the second source.
- Drag a table from the new connection onto the canvas and relate or join it to a table from the first connection.
This adds a second connection, not a second data source: in the worksheet it works as one combined data source. Tableau colours the tables and columns to show which connection each comes from. Joining across connections is called a cross-database join. Some limits apply: unions must come from the same connection, and only calculations that every connection supports are available.
Data blending is different: it combines two separate data sources in a worksheet, one primary and one secondary, added with Data > New Data Source.
Exam tip: A .tds saves the work you did on the data source, not the data itself. If someone needs the data too, for example the extract, share a .tdsx or a .twbx.
Relationships, joins and unions
A data source has two layers:
- The logical layer is the canvas you see first. Tables here are logical tables, connected by relationships, drawn as flexible lines sometimes called noodles.
- The physical layer is inside each logical table. Double-click a logical table to open it, then join or union physical tables into it.
Relationships
A relationship describes how two tables are related, using one or more matching fields, such as Order ID, but doesn't merge them. The first table on the canvas is the base table; drag another table next to it and drop it when the noodle appears. You don't choose a join type: Tableau picks the right joins for each view, querying only the tables the view needs.
- Each table keeps its own level of detail, so values aren't duplicated. A table of targets by region and a table of orders can be related without inflating sales.
- Unmatched values are kept rather than dropped.
- The matching fields must have the same data type, and you can't relate tables on geographic fields.
- Performance options describe the cardinality (one or many) and referential integrity (some or all records match). They're optional: the defaults, many-to-many and some records match, are a safe choice.
Joins
A join combines two tables side by side into one table, matching rows on one or more fields.
| Join type | Keeps |
|---|---|
| Inner | Only rows that match in both tables |
| Left | All rows from the left table, plus matching rows from the right |
| Right | All rows from the right table, plus matching rows from the left |
| Full outer | All rows from both tables, matched where possible |
Unmatched values from the other table become nulls. Because a join produces a single table at the most detailed level, values can be duplicated: joining orders to order lines repeats each order's shipping cost on every line, and summing it gives too large a total.
Unions
A union appends rows from tables that have the same structure, such as sales for January, February and March in separate sheets. The tables must come from the same connection, and fields are matched by name. Drag a table under another in the physical layer, or use a wildcard union to include every matching file or sheet automatically. Tableau adds fields such as Sheet and Table Name, showing where each row came from.
Join or relationship?
| Use a relationship when | Use a join when |
|---|---|
| Tables are at different levels of detail, such as orders and targets | You need a specific join type, such as an inner join to keep only matching rows |
| You want Tableau to keep each table's detail and avoid duplicates | You want to merge tables into one physical table at a single level of detail |
| You aren't sure: relationships are the default | You're combining tables in the physical layer of one logical table |
Exam tip: Relationships are the default and the safe choice for tables at different levels of detail. A join merges tables into one, so watch for duplicated values and dropped rows. A union stacks rows; a join adds columns.
Managing field properties
Once connected, you tidy fields so views are clear. These changes are saved with the data source and don't change the underlying data.
Rename a field
Right-click a field in the Data pane and choose Rename, or double-click a column name on the Data Source page, for example Sub-Category to Product Type. The name in the data source doesn't change, and you can reset the original name later.
Alias a value
An alias changes how a value (member) of a dimension is displayed, without changing the data. Right-click the dimension in the Data pane, choose Aliases, and enter a new name for a member; Clear Aliases resets them. For example, show the value Central as Midwest, or M and F as Male and Female. Aliases work only for discrete dimensions: not for measures, dates or continuous dimensions.
Assign a geographic role
To map a field, give it a geographic role: in the Data pane, select the field's data type icon (or right-click it), choose Geographic Role and pick a role such as Country/Region, State/Province, City or ZIP Code/Postcode. The field's icon changes to a globe, and Tableau adds Latitude (generated) and Longitude (generated) to the measures in the Data pane, so its values can be placed on a map. Tableau assigns roles automatically to fields it recognizes.
Change a data type
Each field has a data type, shown by its icon:
| Icon | Data type |
|---|---|
| Abc | String (text) |
| # | Number (decimal or whole) |
| Calendar | Date |
| Calendar with clock | Date and time |
| T|F | Boolean (true or false) |
| Globe | Geographic values |
To change it, select the type icon on the Data Source page or in the Data pane, or right-click the field in the Data pane and choose Change Data Type. For example, change a postal code stored as a number to a string so leading zeros aren't lost, or a date that was read as text to a date so you can drill down and use date calculations. Change data types before you create an extract.
Change default properties
Right-click a field and choose Default Properties to set how it appears every time it is used:
| Property | Applies to | Example |
|---|---|---|
| Number Format | Measures | Currency with no decimals |
| Aggregation | Measures | Average instead of Sum |
| Total Using | Measures | How totals are calculated |
| Color | Dimensions and measures | Always show Technology in blue |
| Shape | Dimensions | Always use a star for Furniture |
| Sort | Dimensions | Always list High, Medium, Low in that order, in views and filters |
| Date Format | Dates | Show dates as 22/11/2026 |
| Comment | Any field | A note shown in the field's tooltip |
Exam tip: Rename is for field names; aliases are for values of a dimension. Default properties change a field everywhere it's used. Formatting a single view changes only that view.
Hands-on exercise
Prepare a sales data source
Connect, model and tidy a data source so it's ready to share.
Use a free Salesforce Developer Edition org — never a production org.
0 of 7 steps done
How to check your work: Your data source relates Orders and Returns rather than joining them, the alias and rename show in the view, Sales is formatted as currency everywhere, and you can explain what the .tds file contains and what it doesn't.
Domain quiz: Connecting to and Preparing Data
10 questions from the 47 in this domain, different each time and checked as you go. Anything you miss is saved to Mistakes review.
- Questions
- 10
- Time
- Untimed
- Feedback
- After each answer
New questions each time you start, drawn from the bank, unseen ones first.