web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

TRIM function not working for variables?

(0) ShareShare
ReportReport
Posted on by 10

Dear all,

I know there were already some discussions regarding "TRIM" function, but there is something strange happening in my flow for string variables and maybe someone else has already encountered this and could help.

You can find below my flow:

Capturex.PNG

And also the final result:

Captureddd.PNG

So the TRIM function for the "EmailContent" variable defined by me is not working, spaces are not removed = trim(variables('EmailContent'))

Instead, for the HTML to Text is working = trim(body('Html_to_text'))


Anyone knows why is this happening? and how can I make it work also for variables?

Thanks!

 

I have the same question (0)
  • Verified answer
    MJain Profile Picture
    2,450 on at
    Re: TRIM function not working for variables?

    Hi @alexmia ,

     

    Trim is used for removing leading and trailing spaces from the text . Following is the step by step to do so :

    https://debajmecrm.com/how-to-remove-trailing-spaces-and-extra-spaces-in-a-string-in-power-automate/

     

    Thanks

  • Pstork1 Profile Picture
    68,271 Most Valuable Professional on at
    Re: TRIM function not working for variables?

    I think you've been looking at the documentation for Trim() in Power Apps.  In Power Apps it removes all extra spaces from a string.  But in Power Automate (or Azure Logic Apps) Trim() only removes leading and trailing spaces.  Its like TrimEnds() in Power Apps.  Check the docs here: Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

  • alexmia Profile Picture
    10 on at
    Re: TRIM function not working for variables?

    Thanks a lot for your answers!

    I used the workaround mentioned by @ManishJain  and it worked for me.
    However, it would be nice to have also a trim() function in Power Automate that removes all extra spaces in a string.

  • AW0522 Profile Picture
    7 on at
    Re: TRIM function not working for variables?

    I used the Replace function (instead of trim) to remove the blank space in between the string and it works lovely. 

    Example: variableOne = My Test File

    Use Expression:  Replace (variables('variableOne'), ' ','')

    Result:  MyTestFile

     

    Hope this is helpful. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 691 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 431 Moderator

#3
developerAJ Profile Picture

developerAJ 266

Last 30 days Overall leaderboard