Description
Use this function to remove leading, trailing, and excess spaces from text. Supported in Chains.
TRIM is useful for cleaning up text data by removing unnecessary spaces.
Syntax
TRIM(text)
Inputs
This function accepts the following argument:
| Name | Required | Description | Valid input |
|---|---|---|---|
text |
Yes | The text from which you want to remove spaces. | Any text string or cell reference containing text. |
Example
Sample data
| A | B | ||
|---|---|---|---|
| 1 | Hello World ! | 45 | |
| 2 | This is a spacey sentence. | This is a spacey sentence. | |
| 3 | First | Name | |
| 4 | Middle | Branch | |
5 |
67 | Last |
Sample formulas
| Use case | Formula | Explanation and Result |
|---|---|---|
| Clean up a text value that has extra spaces at the start, end, or in between words. | =TRIM(A1) |
Removes the leading, trailing, and doubled-up spaces from " Hello World !". Result: Hello World ! |
| Fix a sentence that has inconsistent or doubled-up spacing between words. | =TRIM(A2) |
Collapses the extra spaces between "This", "is", "a", "spacey", and "sentence." down to single spaces. Result: This is a spacey sentence. |
| Combine several untidy text fields — like a first, middle, and last name — into one cleanly spaced string. | =TRIM(CONCATENATE(A3, A4, B5)) |
Joins the three name pieces together, then removes the leading, trailing, and doubled-up spaces left over from the join. Result: First Middle Last |
Notes
- TRIM removes all spaces from the beginning and end of a text string.
- It also reduces multiple spaces between words to a single space.
- TRIM doesn't affect spaces represented by non-breaking space characters.
Tips
- Use TRIM to clean up data imported from other sources that may contain inconsistent spacing.
- Combine TRIM with other text functions such as CONCATENATE for more complex text manipulation.
- TRIM is particularly useful when preparing data for analysis or presentation. It's also useful for diagnosing failed formulas (by removing extra blank characters).