Package homeTableau Data AnalystStudy guide
Study guide

Chapter 124% of the exam15 min

Connect to and Transform Data

How to choose and connect to a data source, decide between a live connection and an extract, clean and combine data in Tableau Desktop with relationships, joins, unions and blends, reshape data in a Tableau Prep flow, and set up fields with the right names, defaults and roles.

By the end of this chapter you can

  • Choose a data source and decide between a live connection and an extract
  • Connect with custom SQL or to a published data source, and replace the data source behind a sheet
  • Assess data quality and clean data with Data Interpreter, pivot, split and folders
  • Choose between relationships, joins, unions and blends, and between extract filters and data source filters
  • Pick the Tableau Prep step that fits a business scenario: clean, filter, aggregate, pivot, join, union or output
  • Set default properties, rename fields, create aliases and convert fields between roles

Connecting to data sources

Scenario: A retail analyst has orders in a SQL Server database, targets in an Excel workbook and a certified sales data source on the company's Tableau Cloud site. Before building anything, they must decide what to connect to and whether Tableau should query it live.

Choosing a data source

The Connect pane on the Start page lists what Tableau Desktop can reach: Search for Data > Tableau Server for content on Tableau Server or Tableau Cloud, file types, server types (with More for the full list) and Saved Data Sources.

Connect to Choose it when Watch for
A published data source A curated, shared source already exists You need the Connect permission, and you can't join it or edit its aliases
A relational database The data lives in tables on a server You need the driver, the server name and a sign-in
A spreadsheet or text file The data is a local file Titles and merged headers confuse Tableau: use Data Interpreter
A .hyper file directly You were given only the extract Tableau treats it as the original data, so it can't be refreshed, and the relationships saved in the data source file are lost
Custom SQL You need a specific query, not whole tables Tableau runs the query exactly as written

To work offline with a published data source, or to change it without touching the original, choose Data, the data source, then Create Local Copy.

Each file type has its own connector under Connect:

Connector Reads Worth knowing
Microsoft Excel .xls, .xlsx, .xlsm Worksheets, named ranges and Excel tables are each listed as a table. Excel pivot tables are not supported
Text File .csv, .txt, .tab, .tsv Text file properties, on the table's menu, sets the field separator, text qualifier, character set and locale (which decides the decimal mark)
PDF File .pdf Scan PDF File asks which pages to search for tables: all, a single page or a range. Rescan PDF file changes the pages later
JSON File .json Select Schema Levels decides which nested levels become fields
Spatial file Shapefiles, KML, GeoJSON, TopoJSON, MapInfo tables, Esri File Geodatabases Adds a Geometry field. A shapefile needs its .shx, .dbf and .prj files in the same folder as the .shp file

For a database, pick the connector, enter the server name and sign in, then drag tables to the canvas. Add next to Connections puts a second database or file in the same data source, which is what relationships and cross-database joins need. Data > New Data Source creates a separate data source, which is what a blend needs.

Live connection or extract

Live Extract
Queries The source, every time the view changes A .hyper snapshot
Freshness Always current As of the last refresh
Speed Depends on the source Usually faster, and takes load off the database
Offline No Yes
Functions Whatever the source supports Adds functions the source may lack

Choose Live or Extract at the top right of the Data Source page, and select Edit next to Extract to open the Extract Data dialog.

Creating an extract: the original database or file passes through the Extract Data dialog to become a .hyper extract that the workbook queries. The dialog has five groups of settings. Data Storage chooses Logical Tables, the default, or Physical Tables. Filters keep only the rows that match a condition. Aggregation aggregates measures for the visible dimensions and can roll dates up to a level such as month or year. Number of Rows extracts all rows, a sample or the top N rows. Incremental refresh adds only the rows that are new in a chosen column. Filters, aggregation and Top N need Logical Tables, incremental refresh needs All rows and no aggregation, and hidden fields are left out of the extract. Database or file the original data Extract Data dialog five groups of settings .hyper extract queried by the workbook Data Storage Logical Tables (the default) or Physical Tables Filters keep only the rows that match a condition Aggregation visible dimensions and roll up dates to month or year Number of Rows all rows, a sample, or the top N rows Incremental refresh: add only rows that are new in a chosen column Filters, aggregation and Top N need Logical Tables. Hidden fields are left out of the extract. Incremental refresh needs All rows and no aggregation.
The Extract Data dialog has five groups of settings that decide what goes into the .hyper file

  • Logical Tables is the default storage and is required for extract filters, aggregation and Top N. Physical Tables joins at query time, which can make the file smaller when a join multiplies rows.
  • Aggregate data for visible dimensions stores one row per combination of the visible dimensions. Add Roll up dates to store months or years instead of days.
  • Incremental refresh adds only the rows that are new in a column you choose, such as a date or an increasing ID. It needs All rows and is unavailable with aggregation. A full refresh replaces everything, and is needed after the source's structure changes.
  • Hidden fields are left out, so Hide All Unused Fields shrinks an extract.

The extract is built when you go to a sheet. Save the workbook afterwards, or it reopens connected to the original data.

Custom SQL

On the Data Source page, double-click New Custom SQL and enter a single SELECT statement. The result appears as a table in the logical layer. Good reasons to use it: the database has no union option, a field must be cast so that two data types match for a join, the data must be cut down before it reaches Tableau, or the source has no Pivot option.

SELECT * FROM November
UNION ALL
SELECT * FROM December

Insert Parameter swaps a literal value in the query for a Tableau parameter. A parameter can't stand in for a table name or an expression. Name each column with AS, because two columns with the same name cause errors when you use them.

Replacing a data source

  1. Connect to the new source with Data > New Data Source.
  2. On a sheet that has at least one field in the view, choose Data > Replace Data Source.
  3. Pick the Current and Replacement data sources. Select Replace current worksheet only to change one sheet.

Fields you created in the original data source, such as calculated fields, are copied across. Folders are not. A field whose name differs in the new source is marked invalid: right-click it and select Replace References to map it to the matching field.

Exam tip: "Reduce load on the database", "work offline" or "use a function the database lacks" point to an extract. "Up to the second" points to live. Custom SQL is the answer only when the canvas can't do the job, because Tableau can't optimise a query it must run as written.

Preparing data for analysis

Scenario: A finance analyst receives a budget workbook with a title row, merged headers and one column per month, plus a customer list in which one field holds values such as "Lyon, France". None of it can be charted as delivered.

Assess quality first

Check Question Typical signs
Completeness Are rows or values missing? Nulls, blank cells, a month with no rows
Consistency Is each thing written one way, with one data type? "UK" and "United Kingdom", dates stored as text, mixed units
Accuracy Are the values right? Totals that don't match a trusted report, impossible dates, duplicated rows after a join

The data grid on the Data Source page shows the first 1,000 rows, and the metadata grid lists every field as a row. For a column with mixed values, Tableau picks one data type from the first 10,000 rows of an Excel sheet (1,024 for a CSV), and values that don't fit, such as text in a number column, become null.

Cleaning in Tableau Desktop

Tool What it fixes Limits
Use Data Interpreter Titles, notes, footers, empty cells and sub-tables in Excel, CSV, PDF and Google Sheets data Does not pivot, and never changes the file. Review the results opens a marked-up copy in Excel
Pivot A column per month or year: select two or more columns in the grid and choose Pivot to get one names field and one values field Columns to rows only, and only for Excel, text, Google Sheets and PDF data. Elsewhere, use custom SQL or Tableau Prep
Split and Custom Split One string field holding several values Split finds the separator itself. Custom Split lets you name it and take the first N, last N or all parts
Data type icon A field read as the wrong type Change it before you create an extract

The results of a split are ordinary calculated fields built on the SPLIT function, which you can also write yourself:

SPLIT([Customer Location], ", ", 2)

For "Lyon, France" this returns the second part, France. Split fields can't be used as join keys or in a pivot.

Folders

Folders tidy a long Data pane. Open the Data pane menu, choose Group by Folder, select fields, then right-click and choose Folders > Create Folder. A field sits in one folder only. Unlike a hierarchy, a folder adds no drill-down. A data source with several tables lists fields by table until you switch to Group by Folder, and only then is Create Folder offered. Drag a field onto a folder to add it.

Relationships, joins, unions and blends

Four ways to combine data in Tableau Desktop. A relationship is made in the logical layer of the Data Source page: you only match fields, the tables stay separate and Tableau builds the joins each sheet needs. A join is made in the physical layer: it adds columns and merges the tables into one fixed table using the join type you pick. A union is also made in the physical layer: it adds rows by stacking tables that have the same columns. A blend is made on one worksheet: the data sources stay separate, each is aggregated first and the results are then linked like a left join from the primary source. Start with a relationship, join for a fixed table, union to stack rows and blend to link per sheet. Relationship logical layer match fields only; tables stay separate, joins made per sheet Join physical layer adds columns; one fixed table, you pick the type Union physical layer adds rows; tables need the same columns Blend on one worksheet separate sources; aggregate first, then link like a left join Start with a relationship. Join for a fixed table, union to stack rows, blend to link per sheet.
Four ways to combine data: a relationship, a join, a union and a blend

Method What you define Choose it when
Relationship Matching fields between two logical tables, with no join type Almost always, and especially when tables are at different levels of detail, such as orders and monthly targets
Join A join type (inner, left, right, full outer) and join clauses between physical tables You want one fixed table, or you want unmatched rows deliberately filtered out
Union Tables to stack, by hand or with Wildcard (automatic) Files share the same columns, such as one sheet per month
Blend Linking fields between separate data sources, per sheet The link must change from sheet to sheet, or a source can't be related or joined, such as a cube
  • Relationships need fields of the same data type. Tableau builds the joins each sheet requires, so measures are not duplicated and unmatched values are not dropped. The Performance Options default to many-to-many and some records match. Change them only when you are sure of the data.
  • Joins are made by double-clicking a logical table to open the physical layer. An inner join drops unmatched rows, and joining a detailed table to a summary table repeats the summary values.
  • Unions start with New Union. Fields are matched by name, and Tableau adds fields such as Table Name that record where each row came from. When names differ, select the columns and choose Merge mismatched fields.
  • Blends start when a sheet uses fields from two data sources. The first one used becomes the primary. The secondary is aggregated and then linked, so only values that exist in the primary appear, as in a left join. An asterisk means several secondary values matched one mark. Set links with Data > Edit Blend Relationships.

Published data sources can't be joined. Relate them (Tableau 2026.2 and later) or blend them.

Extract filters and data source filters

Filter Limits Set it from
Extract filter The rows copied into the extract Filters in the Extract Data dialog
Data source filter Every sheet that uses the data source, live or extract Filters > Add on the Data Source page

Both are applied before any filter on a worksheet. People who connect to a published data source can't see or change its data source filters.

Exam tip: Read for the level of detail. Tables at different levels, or "avoid duplicated totals", means a relationship. "Stack monthly files" means a union. "Different linking field on each sheet" means a blend. Data Interpreter removes clutter but never pivots.

Transforming data in Tableau Prep

Scenario: An operations analyst receives a sales file from each region every month. Column names differ, product names are typed inconsistently, and the survey export has one column per question. The same clean-up must be repeated every month, so it belongs in a flow.

A Tableau Prep flow runs from Input steps to Output steps. The Flow pane shows the steps, the Profile pane shows the distribution of values in each field, and the Changes pane lists every operation in order.

A Tableau Prep flow runs from left to right through steps. An Input step connects to files or tables. A Clean step fixes, filters, splits and renames. A Join step adds columns from another input. An Aggregate step groups the rows to a new level of detail. An Output step writes a file, a published data source or a database table. Other steps can be added anywhere after the input: a Union step appends rows from inputs with the same fields, a Pivot step turns columns into rows or rows into columns, and a New Rows step fills gaps in a sequence of dates or whole numbers. While you build, Tableau Prep shows a sample of the data, and running the flow processes every row and writes the output. Input connect to files or tables Clean fix, filter, split and rename Join add columns from another input Aggregate group to a new level of detail Output file, published source or table A flow runs from left to right Other steps you can add anywhere after the input Union append rows from inputs with the same fields Pivot columns to rows, or rows to columns New Rows fill gaps in a sequence of dates or whole numbers While you build, Tableau Prep shows a sample. Running the flow processes every row.
A Tableau Prep flow runs from an Input step through cleaning and shaping steps to an Output step

Matching the step to the need

Business need Use
Product names are spelled several ways Clean step: Group Values
Test rows or old years must go A filter, in almost any step
One row per customer is needed before joining to a customer table Aggregate
Monthly files with the same fields become one table Union
Customer attributes are added to each order Join
A column per month becomes a Month field and a Value field Pivot, columns to rows
One row per metric becomes one column per metric Pivot, rows to columns
A daily series has missing dates New Rows

Clean and filter

Cleaning operations are available in most steps, not only in a clean step. None are available in an Output step.

  • Group Values maps variants to one value, by Manual Selection or with the fuzzy matches Pronunciation, Common Characters and Spelling.
  • Clean offers quick fixes such as Make Uppercase, Trim Spaces and Remove Punctuation.
  • A data role, such as Email or City, marks values that are not valid for the role with a red exclamation mark.

To filter, right-click a value and choose Keep Only or Exclude, or pick a filter type: Calculation, Wildcard Match for strings, Range of Values for numbers, Range of Dates and Relative Date for dates, plus Null Values and Selected Values. Selected Values can list values that are not in the sample. In an Input step, Calculation is the only filter type, but filtering there cuts the data the whole flow has to process.

Join, union and aggregate

A join step defaults to an inner join. Besides left, right and full, Tableau Prep offers leftOnly, rightOnly and notInner, which return only the rows that do not match. They quickly find orders with no customer record. The Summary of Join Results counts the rows included and excluded from each side, and values that fail the join clause appear in red so you can edit them in place.

A union step takes up to 10 inputs. Fields with different names end up as separate fields full of nulls: drag one onto the other, or use Merge Fields. For many files of the same shape, a Wildcard Union in the Input step is simpler.

An aggregate step has two panes. Grouped Fields define what one row is. Aggregated Fields are summarised to that level with SUM, AVG and so on. Only fields placed in one of the panes continue down the flow.

Pivot

Direction From To Notes
Columns to Rows Wide data Tall data Pivot several groups of fields at once. Use wildcard search to pivot picks up new matching fields each time the flow runs
Rows to Columns Tall data Wide data Choose one field whose values become the new columns, and a field to aggregate into them. Change a date field to a string first

Tableau Desktop's own pivot only goes from columns to rows.

Outputs

In an Output step, Save output to decides where the result goes.

Save output to Choose it when
File, as .hyper The result will be analysed in Tableau Desktop
File, as .csv or .xlsx People or tools outside Tableau need the data
Published data source Workbooks on Tableau Server or Tableau Cloud should share the result
Database and Cloud Storage The clean data should be written to a database table

The write option decides what happens to earlier output. Create table builds the table again on each run, Append to table adds rows to it (not available for .csv), and Replace data, for database tables and Excel worksheets, swaps the rows but keeps the existing table's structure. While you build, Tableau Prep works on a sample. Running the flow processes all the data.

Exam tip: Decide whether the scenario changes the number of rows, the number of columns or the level of detail. Fewer rows per entity is Aggregate. More rows from more files is Union. More columns from another table is Join. Column headers that are really data values is Pivot, columns to rows.

Customizing fields

Scenario: A hospital analyst is about to publish a data source for forty colleagues. Fields have names such as adm_dt, ward codes are numbers that Tableau sums, and the occupancy rate shows as 0.8731. Fixing this once in the data source fixes it for everyone.

Default properties

Right-click a field in the Data pane and open Default Properties.

Property What it sets
Aggregation How a measure is aggregated when it is first added to a view, for example AVG for a rate
Number Format How numbers display, for example currency or a percentage. Dates have Date Format
Color and Shape The colour or shape of each member of a dimension, shared by every sheet that uses the data source
Sort The order of a dimension's members in views and in filter lists, for example High, Medium, Low
Comment A description shown when someone hovers over the field in the Data pane

A default is a starting point. Changing the aggregation or format on one pill overrides it for that view only.

To change a data type, click the type icon beside the field in the Data pane or on the Data Source page, or right-click and choose Change Data Type.

Rename or alias

Rename Alias
Changes The name of the field The labels of the members inside a discrete dimension
How Right-click and choose Rename, or press F2 Right-click the dimension and choose Aliases
Limits None on field type Not for measures, continuous dimensions or dates, and not for fields from a published data source

On the Data Source page, double-click a column name in the data grid to rename it. Reset Name on the column's menu restores the original name.

Neither changes the underlying data. A 0 and 1 flag that Tableau reads as a measure can't be aliased until you convert it to a discrete dimension. Then 0 and 1 can become No and Yes.

Dimension or measure, discrete or continuous

A two by two grid of field roles. Columns: discrete fields are blue and draw headers, continuous fields are green and draw an axis. Rows: dimensions are not aggregated and set the level of detail, measures are aggregated, for example with SUM. A discrete dimension such as Category gives one header per member and is the usual kind of dimension. A continuous dimension such as YEAR of Order Date gives an unbroken date axis, and string and Boolean dimensions can't be continuous. A discrete measure such as SUM of Quantity turns each total into a header, which is useful in a text table. A continuous measure such as SUM of Sales gives a value axis and is the usual kind of measure. Converting to dimension or measure changes whether Tableau aggregates, converting to discrete or continuous changes whether you get headers or an axis, and the two choices are independent. Discrete (blue): headers Continuous (green): an axis Dimension not aggregated; sets the detail Measure aggregated, for example SUM Category one header per member the usual dimension YEAR(Order Date) an unbroken date axis not possible for strings or Booleans SUM(Quantity) each total becomes a header useful in a text table SUM(Sales) a value axis the usual measure Convert to Dimension or Measure changes whether Tableau aggregates. Convert to Discrete or Continuous changes whether you get headers or an axis. The two choices are independent.
Dimension or measure decides aggregation, and discrete or continuous decides headers or an axis

Situation Convert
A numeric code, ID or postal code is being summed Convert to Dimension
Each discount rate should be its own bar To a dimension, then to Discrete
A trend along a timeline Date to Continuous
The same month compared across years, as headers Date to Discrete
A total shown as a header beside a dimension in a table Measure to Discrete
How many customers, not which ones Dimension to a measure with Count (Distinct)

Converting in the Data pane sets the default for future views. Converting a pill on a shelf changes that view only. String and Boolean dimensions can't be continuous. On Color, a discrete field gets a categorical palette and a continuous field gets a gradient.

Exam tip: Blue or green and dimension or measure are separate choices. Headers mean discrete, an axis means continuous, and an aggregation such as SUM in the pill means measure. If Aliases is missing from the menu, the field is a measure, a date, continuous or comes from a published data source.

Hands-on exercise

Model, extract and tidy Superstore

Build a small data source from Sample - Superstore with a relationship, a join and a filtered extract, customise its fields, then repeat one clean-up as a Tableau Prep flow.

Use a free Salesforce Developer Edition org — never a production org.

0 of 8 steps done

How to check your work: The Desktop data source shows only Furniture rows, Ship Mode shows Priority instead of First Class, Discount draws one header per discount rate, and the Tableau Prep output has one row per region.

Domain quiz: Connect to and Transform Data

10 questions from the 68 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.

Explore and Analyze Data