Power Automate trim() Function [How to Use]

In this Power Automate tutorial, I will explain what the trim() function in Power Automate is and how to use the Power Automate trim() function with its syntax.

The Power Automate trim() Function is used to remove leading and trailing whitespaces from a text string. To use the trim() function, you typically incorporate it into an expression within a Power Automate action or condition.

Power Automate trim() Function

The Power Automate trim() function removes leading and trailing whitespaces from a text string.

For example, there is a text input string like “ Hello Lynne Robbins Welcome back!“. After using the Power Automate trim() function, the output will be “Hello Lynne Robbins Welcome back!

Here, it is removing the first space from the given string. Refer to the image below:

Power Automate trim() Function

This briefly introduces the trim() function in Power Automate.

Power Automate trim() Function Syntax

The syntax of the trim() function in Power Automate is mentioned below.

trim('<text>')

Where,

  • text (mandatory): The string that should be trimmed (removal of leading and trailing whitespace).

This is the Power Automate trim() function syntax.

How to Use trim() Function in Power Automate

Let’s see how to use Power Automate’s trim() function by creating an instant cloud flow that gets triggered manually.

Example:

I want to remove leading whitespaces from a given text string in this scenario. Here, I have taken a string with a value like ” Hello Lynne Robbins Welcome back!”.

Then, the trim() function will return the value after removing the leading whitespaces from the given text string “Hello Lynne Robbins Welcome back!”.

How to use trim() function in Power Automate

To achieve this, follow the steps below.

1. Open the Power Automate home page in your browser, click + Create -> Select the Instant cloud flow -> Enter the flow name, and choose the trigger’s flow (Manually trigger the flow) -> Click Create button.

2. Next, add the ‘Initialize variable’ flow action to store the value of text during the flow and set all the details.

  • Name: Give the name of the initialized variable.
  • Type: Select the type of variable as String.
  • Value: Here, I have given the‘ Hello Lynne Robbins Welcome back!’ value of the variable.
Power Automate trim() function expression

3. Add the ‘Compose’ flow action to set the trim() expression to remove the leading whitespaces from a given text string.

  • Inputs: Select field -> Click Expression -> Insert the code -> Then click on OK.
trim(variables('Grettings'))

Where it evaluates the value stored in the variable ‘Greetings’ and removes any leading or trailing whitespaces.

How to use trim() function expression in Power Automate

4. Now, it’s time to Save and Test -> Then test it Manually. The compose flow action will display the output according to the trim() function expression below.

Power Automate trim() function format

This is how to use the trim() function in Power Automate.

Conclusion

I hope this Power Automate tutorial helps you learn and understand the step-by-step procedure for using the trim() function in Power Automate.

Along with this, I have shown the syntax of the trim() function in Power Automate.

Moreover, you may like some more Power Automate function tutorials: