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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / TRIM function not work...
Power Automate
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!

 

Categories:
  • Verified answer
    MJain Profile Picture
    2,450 on at

    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
    69,665 Most Valuable Professional on at

    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

    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

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 445

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 300

Last 30 days Overall leaderboard