In the vast array of utilities that Google Data Studio offers, the
TRIM
function holds its unique place for dealing with text data. In essence, this function aids in maintaining clean data by removing any extra spaces present at the beginning or end of a text string. The applicability of TRIM
spans across various spheres that require string manipulation, data cleaning, or simply enhancing the formation of your information.
Syntax:
TRIM(X)
The TRIM
function expects a single parameter X
, which denotes the text you wish to manipulate. X
can be literal text, a field from your data source or an expression containing at least one field.
The
TRIM
function works by examining the text in question ("X") and removing any superfluous space characters that may exist at the starting or ending of the text string. It's vital to note that TRIM
will not alter spaces within the text - only those that lead or trail it.
Consider a sales analysis for a company where your data includes sales campaign names with erratic spaces in strings. Working with such data can introduce inaccuracies or lead to incorrect data mapping. The
TRIM
function comes into play to save time and preserve consistency.
Here's an example of how to use
TRIM
in such scenario:
" March 2021 Sales Campaign "
.
Using TRIM
, you can clean up this string by the command: TRIM(Campaign Name)
.The cleaned up output will be:
"March 2021 Sales Campaign"
, free of leading and trailing spaces.
" Product A "
, you can use TRIM(Product Name)
to fetch a cleaned up "Product A"
.Although the
TRIM
function is a straightforward and powerful tool for data cleaning, it isn't without its limitations. It only trims spaces at the ends of the string and doesn't affect spaces within the string itself.
If your data contains inconsistent or extra spaces between words, you will likely need additional data transformation or cleaning steps.
If your data set contains entries with additional spaces within the text, consider using a combination of functions like
REPLACE
along with TRIM
to solve your problem.
TRIM
is case-sensitive and does not remove other forms of white space characters like tabs or non-breaking spaces.
TRIM
works excellent with other string manipulation functions. You can pair it with Upper or Lower functions to standardize your data sets.
Brad Pitt Professional Copywriter on Google Data Studio Function: TRIM
Remember, data manipulation is an art, and with functions like
TRIM
, you are the artist- doling out polished representations of information from raw, unclean data.Become a Looker Studio expert
for free
Learn all the secrets of data analysis and create beautiful and effective dashboards thanks to our 30-second video courses! Join Catchr's community on YouTube.
Get more video lessonsAll your data on Looker Studio
Build Looker Studio dashboard easily with your marketing data from all platforms and track your essential KPIs! No-code integration.
Start free trial now!Optimize your data analysis
Get free Looker Studio dashboard template among a large collection of +50 stunning template! Elevate your data visualization.
Get free templates!