Power Automate Trim Function Explained

Power Automate Trim Function

To trim spaces from string the Power Automate trim function is the right choice. The trim function removes all leading and trailing spaces from your text. It does not remove whitespace that is surrounded by characters.


Power Automate Trim Function

The Power Automate trim function returns a string, where leading and trailing whitespace is removed.

Syntax

trim('<text>')

Input parameters

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

Return value

  • The given string without leading and trailing whitespace.

Power Automate Trim Expression Examples

trim('  abc ')
=> "abc"

trim('abc')
=> "abc"

trim(' abc def')
=> "abc def"

How To Use The Trim Function In Power Automate

In this how to you will learn, how to trim a variable in Power Automate. You will learn how to use the Trim function to transform ‘ Hello, Joe! ‘ to ‘Hello, Joe!’.

  1. Create a new flow, give it a name (1), select ‘Manually trigger a flow’ (2) and click ‘Create’ (3)

    Power Automate Trim Function New Flow

    Create a new flow

  2. Add a new Initialize variable step: Search for ‘initialize’ (1) and select the ‘Initialize variable’ action (2)

    Power Automate Trim Function Initialize variable

    Add Initialize variable step

  3. Configure Initialize variable action: Name = ‘text’ (1), Type = ‘String’ (2) and Value = ‘ Hello, Joe! ‘ (3)

    Power Automate Trim Function initialize variable string variable

    Set up variable text

  4. Add a compose step: Search for ‘compose’ (1) and select ‘Compose’ (2)

    Power automate trim add compose step

    Add a compose step

  5. Configure Compose Action: Click into Inputs input field (1) and enter ‘trim(variables(‘text’))’ in the expression editor (2) and click ‘Update’

    Power Automate Trim

    Trim function in Power Automate flow

  6. Do a test run

    Power Automate Trim Function Test Run

    Check result without spaces


Leave a Comment

Your email address will not be published.