Splitting and Cleaning Data Fields in Tableau
Definition: Splitting and cleaning data fields are important data preparation activities in Tableau. Splitting separates multiple pieces of information stored in one field into separate fields, while cleaning improves data quality by correcting inconsistent values, removing unnecessary spaces, renaming fields, handling nulls, and removing unwanted data.
Example: A Customer Name field contains "Amit Sharma". Splitting can create separate First Name and Last Name fields. Cleaning can remove extra spaces, correct inconsistent spellings, and standardize the values for accurate analysis.
Course: JustAcademy Tableau Training
Course Demo: Register for a Tableau Course Demo
1. What Is Splitting Data Fields?
Splitting is a data transformation technique that separates a single string field containing multiple pieces of information into two or more fields. Tableau can split values using a common separator, such as a space, comma, hyphen, or pipe character.
For example, a field named Full Name may contain first and last names in the same column. Splitting it creates separate fields that can be used for filtering, grouping, sorting, and visualization.
Example Before Splitting
| Customer ID |
Full Name |
| 101 |
Amit Sharma |
| 102 |
Priya Patel |
| 103 |
Rahul Verma |
Example After Splitting
| Customer ID |
First Name |
Last Name |
| 101 |
Amit |
Sharma |
| 102 |
Priya |
Patel |
| 103 |
Rahul |
Verma |
After splitting, each name component is available as a separate field. This makes it easier to analyze customers by first name, last name, or other relevant attributes.
2. What Is Cleaning Data Fields?
Cleaning data fields means improving the consistency, accuracy, and usability of field names and field values before analysis. Raw datasets may contain extra spaces, inconsistent capitalization, misspellings, missing values, duplicate records, mixed formats, or incorrect data types.
Example Before Cleaning
| Customer Name |
City |
Sales |
| " Amit Sharma " |
mumbai |
15000 |
| Priya Patel |
Mumbai |
18000 |
| RAHUL VERMA |
MUMBAI |
12000 |
Example After Cleaning
| Customer Name |
City |
Sales |
| Amit Sharma |
Mumbai |
15000 |
| Priya Patel |
Mumbai |
18000 |
| Rahul Verma |
Mumbai |
12000 |
Cleaning makes the values more consistent. The exact transformations depend on the data and business requirements; for example, capitalization changes should be applied carefully when the original formatting carries meaning.
3. Why Are Splitting and Cleaning Important?
- Improve data quality: Reduce inconsistent values and formatting problems.
- Make analysis easier: Separate information into meaningful fields.
- Improve filtering: Filter using individual components such as city, department, first name, or product code.
- Support grouping: Group records by meaningful categories.
- Improve visualizations: Use clean fields in charts, tables, dashboards, and filters.
- Reduce reporting errors: Standardize values so similar records are treated consistently.
- Prepare data for combining: Clean fields before joining or unioning datasets where appropriate.
- Improve readability: Use descriptive field names and consistent values.
4. Types of Splitting in Tableau
A. Automatic Split
Automatic Split allows Tableau to detect a common separator or pattern and split a string field into multiple fields. It is useful when values follow a reasonably consistent format.
Example: "Amit Sharma" can be split using the space between the first and last names.
Depending on the connection and detected pattern, Tableau can generate multiple fields. Automatic split may not work correctly when separators or the number of parts vary significantly between records.
B. Custom Split
Custom Split lets you specify the separator and control how many occurrences are used to split the field. Depending on the available options, you can split at the first occurrences, last occurrences, or all occurrences of the separator.
Example: The value "amit|Sales|Mumbai" can be split using the pipe character (|) into username, department, and city.
| Original Value |
Username |
Department |
City |
| amit|Sales|Mumbai |
amit |
Sales |
Mumbai |
| priya|HR|Pune |
priya |
HR |
Pune |
| rahul|IT|Delhi |
rahul |
IT |
Delhi |
Important: Tableau's Custom Split produces string fields. Review and change the data types if the resulting fields represent dates or numbers.
5. How to Split a Field in Tableau Desktop
Method 1: Split from the Data Source Page
- Open Tableau Desktop.
- Connect to your Excel, CSV, or another supported data source.
- Open the Data Source page.
- Locate the field that contains multiple pieces of information.
- Click the drop-down arrow beside the field name.
- Select Split to let Tableau detect the separator, or select Custom Split to define it yourself.
- Review the newly generated fields in the data preview.
- Rename the fields to meaningful names, such as First Name and Last Name.
- Verify the results before using the fields in a worksheet.
Method 2: Split from the Data Pane
- Open a worksheet in Tableau Desktop.
- Locate the field in the Data pane.
- Right-click the field.
- Select Transform > Split or Transform > Custom Split, depending on your requirement.
- Review the generated fields.
- Rename the fields and check their data types.
Note: The menu-based split options depend on the data source and are available in Tableau Desktop, not as a menu command in browser-based web authoring. In web authoring, a calculated field using the SPLIT function may be an alternative.
Official guide: Tableau Help: Split a Field into Multiple Fields.
6. Using the SPLIT Function in Calculated Fields
Tableau provides a string function named SPLIT that extracts a particular part of a string based on a delimiter.
Syntax
SPLIT(string, delimiter, token number)
- string: The field or text to split.
- delimiter: The character or text separating the parts.
- token number: The position of the part to return, starting from 1. Negative token numbers count from the end.
Example 1: Extract First Name
SPLIT([Full Name], " ", 1)
If Full Name contains "Amit Sharma", the result is "Amit".
Example 2: Extract Last Name
SPLIT([Full Name], " ", 2)
If Full Name contains "Amit Sharma", the result is "Sharma".
Example 3: Extract Department
Suppose Employee Info contains "amit|Sales|Mumbai".
SPLIT([Employee Info], "|", 2)
The result is "Sales".
Example 4: Extract City
SPLIT([Employee Info], "|", 3)
The result is "Mumbai".
Important: SPLIT returns only one token per calculation. Create separate calculated fields when you need multiple parts. Results can be null or unexpected if the delimiter or token position does not match the data.
7. Common Data Cleaning Operations
A. Trim Extra Spaces
Extra spaces at the beginning or end of a value can cause matching and filtering problems. In Tableau Prep, use the available cleaning options to trim spaces. In Tableau calculations, the TRIM function can remove leading and trailing spaces.
TRIM([Customer Name])
Example: " Amit Sharma " becomes "Amit Sharma".
B. Standardize Text Values
Inconsistent capitalization may make values harder to read or compare. Use functions such as UPPER and LOWER when appropriate.
UPPER([City])
For example, "Mumbai" becomes "MUMBAI". Use consistent capitalization according to your reporting standards.
C. Replace Incorrect Values
In Tableau Prep, you can edit values and replace incorrect or inconsistent entries. For example, values such as "Mumabi" and "Mumbai" may need to be standardized after confirming that they refer to the same city.
D. Handle Null Values
Null values represent missing or unknown information. Check whether they should remain null, be replaced, or be excluded from a particular analysis. Do not automatically replace all nulls with zero because that may change the meaning of the data.
E. Rename Fields
Use descriptive field names that explain the data clearly.
| Original Field |
Improved Field Name |
| Cust_Nm |
Customer Name |
| Ord_Dt |
Order Date |
| Tot_Sls |
Total Sales |
| Emp_Dept |
Employee Department |
F. Remove Unnecessary Fields
Remove fields that are not needed for the analysis, provided they are not required by calculations, relationships, joins, or other workbook dependencies. In Tableau Prep, the Remove Field option can be used in supported steps.
G. Correct Data Types
Ensure that numeric values are recognized as numbers, dates as dates, and categorical values as strings. Correct data types are important for calculations, sorting, filtering, and visualization.
8. Cleaning Data Fields in Tableau Prep
Tableau Prep is designed for building repeatable data preparation flows. It provides cleaning operations such as splitting values, trimming spaces, renaming fields, grouping values, editing values, filtering, changing data types, and removing fields.
Steps to Clean Data in Tableau Prep
- Open Tableau Prep Builder.
- Connect to your dataset.
- Add a Clean step to the flow.
- Review the Profile pane and data grid to identify inconsistent values.
- Open the field's More Options menu.
- Choose an appropriate operation, such as Clean, Split Values, Rename Field, or Remove Field.
- Apply the required changes.
- Review the updated values and field names.
- Add further steps if necessary.
- Configure an output and run the flow when the data is ready.
Cleaning in Tableau Prep is useful when you need to document and rerun a sequence of data preparation operations. Tableau Desktop also supports field splitting and other data preparation features, depending on the source and workflow.
Official guide: Tableau Prep Help: Clean and Shape Data.
9. Splitting vs. Cleaning Data Fields
| Basis |
Splitting |
Cleaning |
| Purpose |
Separates multiple pieces of information into different fields |
Improves the quality and consistency of field names and values |
| Typical operation |
Separate Full Name into First Name and Last Name |
Trim spaces and standardize inconsistent values |
| Input |
Usually a string containing multiple parts |
Fields with formatting, quality, or consistency issues |
| Output |
Two or more new fields |
Cleaner fields and more consistent values |
| Common tools |
Split, Custom Split, SPLIT function |
Trim, edit values, rename, group, filter, change data types |
| Example |
"amit|Sales|Mumbai" becomes separate fields |
" Mumbai " is standardized to "Mumbai" |
10. Common Problems and Troubleshooting
| Problem |
Possible Cause |
Solution |
| Split option is missing |
The field is not a string or the data source does not support the option |
Check the field's data type and source capabilities |
| Only one field is generated |
Tableau detected only one split point or the selected pattern has limited parts |
Use Custom Split and specify the separator |
| Some split fields contain nulls |
Some records do not contain the expected separator or token |
Review the original values and handle incomplete records appropriately |
| Names are split incorrectly |
Names may contain middle names, multiple spaces, or different formats |
Review the data structure and use a suitable custom split or calculation |
| Values are truncated or missing |
The separator may be removed during the split operation |
Review the separator and confirm that the resulting fields retain the intended information |
| Numbers are treated as text |
Split-generated fields may be strings |
Change the data type when the values are numeric and valid |
| Inconsistent categories remain |
Values use different spellings or formats |
Standardize confirmed equivalent values and check for unintended changes |
| Calculations stop working |
Referenced fields were renamed, removed, or transformed |
Update the affected calculations and validate the results |
11. Best Practices for Splitting and Cleaning
- Inspect the original data before making changes.
- Identify the separator used in the field before splitting.
- Use automatic split for consistent patterns and custom split when you need more control.
- Use descriptive names for all newly created fields.
- Review records that do not follow the expected pattern.
- Check for null values and blank fields after splitting.
- Confirm data types after transforming string values.
- Standardize categories only after confirming that different values mean the same thing.
- Keep an unchanged copy of the original field when you need it for validation or auditing.
- Check whether any calculations or visualizations depend on fields you rename or remove.
- Validate row counts and key totals before and after cleaning.
- Use Tableau Prep for repeatable cleaning workflows involving multiple operations.
12. Practical Exercise
Task: Split employee details into separate fields and clean inconsistent city values.
Sample Input Data
| Employee ID |
Employee Info |
City |
Sales |
| 101 |
amit|Sales|Mumbai |
Mumbai |
25000 |
| 102 |
priya|HR|Pune |
pune |
30000 |
| 103 |
rahul|IT|Delhi |
DELHI |
22000 |
Instructions
- Connect Tableau to the dataset.
- Split Employee Info using the pipe character (
|).
- Rename the resulting fields to Employee Name, Department, and Work Location.
- Trim extra spaces from City using an appropriate cleaning operation.
- Standardize city capitalization according to a consistent reporting convention.
- Check the Sales field's data type.
- Build a bar chart showing Sales by Department.
- Verify the values and confirm that the transformation has not changed the intended sales amounts.
Expected Learning Outcome
You should be able to split combined fields, clean inconsistent values, rename the resulting fields, and prepare the data for visualization.
13. Interview Questions and Answers
Q1. What is splitting data in Tableau?
Splitting separates a string field containing multiple pieces of information into multiple fields based on a separator or pattern.
Q2. What is the difference between Split and Custom Split?
Split allows Tableau to detect a common separator or pattern automatically. Custom Split lets you specify the separator and how many occurrences to split.
Q3. What is the SPLIT function?
SPLIT is a Tableau string function that returns a specified token from a string based on a delimiter and token position.
Q4. Why is data cleaning important?
Data cleaning improves consistency, readability, and reliability so that filtering, calculations, aggregation, and visualization are more accurate.
Q5. How can you remove extra spaces?
In a Tableau calculation, use TRIM to remove leading and trailing spaces. Tableau Prep also provides a Trim Spaces cleaning operation.
Q6. How do you split a full name into first and last names?
Create separate calculated fields using SPLIT, such as SPLIT([Full Name], " ", 1) for the first token and SPLIT([Full Name], " ", 2) for the second token. This simple method assumes that the name format is consistent.
Q7. Why can split fields contain null values?
A record may not contain the expected separator or may not have enough parts to produce the requested token.
Q8. Can split fields be used in calculations?
Yes. Split-generated fields can generally be used in calculations, filters, and visualizations like other fields, subject to the capabilities of the source and field.
Q9. What is Tableau Prep used for?
Tableau Prep is used to build data preparation flows for cleaning, shaping, and combining data before analysis.
Q10. What should you verify after cleaning a dataset?
Check field names, data types, null values, category consistency, row counts, and important totals.
14. Quick Revision Checklist
- Understand the meaning of splitting data fields.
- Know the difference between automatic split and custom split.
- Understand the SPLIT function and its token number.
- Practice splitting names, employee details, and codes.
- Know how to trim extra spaces and standardize values.
- Learn to rename fields and correct data types.
- Understand how to handle null values and inconsistent formats.
- Know the difference between Tableau Desktop and Tableau Prep cleaning workflows.
- Check calculations and visualizations after field transformations.
- Validate the cleaned data before using it in reports.
15. Learning Resources
Conclusion
Splitting and cleaning data fields are essential steps in preparing reliable data for Tableau analysis. Splitting separates combined information into meaningful fields, while cleaning improves the consistency and quality of the data. By applying the correct transformations, checking data types, handling missing values carefully, and validating the results, you can create more accurate charts, dashboards, and reports.