When string data contains trailing spaces (such as space characters or fixed-length padding), comparison operations and string functions in Tableau (Tableau Desktop, Tableau Prep Builder, Tableau Server and Tableau Cloud) may produce unexpected results.
This issue typically manifests in the following two ways:
Issue A: Filter or Join key mismatch
Trailing spaces in source data columns prevent exact match filters (=) or join conditions from matching, resulting in zero records displayed or extracted.
Issue B: LEN() function returns incorrect values (identical values for all records)
For fixed-length CHAR(n) columns, Tableau may not remove this padding, causing LEN() to return a length equal to n for every record.
This behavior is caused by source data quality issues or database-specific column type specifications (CHAR vs. VARCHAR).
Data Quality Issue
Trailing spaces directly embedded in the source data will cause exact match comparisons to fail regardless of database type or connection mode.
Database Product and Column Type Behavior
CHAR(n) columns contain trailing padding spaces to maintain fixed length. When connect to certain databases like SQL Server, right-trimming may occur, whereas other databases like Oracle retain padding spaces.
To ensure consistent results across different database engines, perform the following steps:
Explicitly remove trailing spaces when performing string comparisons, filtering, or calculating string length.
For filters or join keys, use explicit trimming:
"Value" = TRIM([Field_Name])
or
CONTAINS([Field_Name], "Value")
For string length calculations, wrap the field with RTRIM() or TRIM():
LEN(RTRIM([Field_Name]))
or
LEN(TRIM([Field_Name]))
Check the data type definition of the column in the source database.
If the column is defined as fixed-length CHAR, recognize that padding is expected database behavior.
If the column is VARCHAR but still contains trailing spaces, perform data cleansing in the source database to strip unnecessary spaces.
TRIM, CONTAINS, and LEN.005391125

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.