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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / MS Flow Variable Remov...
Power Automate
Unanswered

MS Flow Variable Remove Last Character In a String

(0) ShareShare
ReportReport
Posted on by 21

I am trying to remove the last character from a string variable in MSFlow.  I've tried several things but so far no luck.  Any feedback on the best way to do this?  

Categories:
I have the same question (0)
  • Brad_Groux Profile Picture
    4,556 on at

    There are a few ways to do this, but nearly all of them revolve around utilizing the Compose action. See the Functions documentation for Flow, and the Using Functions within Flow using the Compose Action blog post for some further ideas on how it can be used.  

    If you could provide an expanded screenshot of your Flow and steps, and of any detailed error messages you're receiving we could likely better assist you.

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • Verified answer
    ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @bclarkuncc 

    This should help....

    In my example, I have a string called varString.

    The expression that I used to get all but the last character is:

    substring(variables('varString'),0,add(length (variables('varString')),-1))

     

    The substring function allows me to extract part of a string - I specify where to start (position 0) and how many characters I want.

    To find how many characters to take, I use the length expression to give me the string length and subtract one for the result.

     

    Substr1.jpgSubstr2.jpg

     

     

  • v-bacao-msft Profile Picture
    on at

    Hi @bclarkuncc ,

     

    The methods provided by Scott are valid, and you could also consider using take() function.

    take(variables('String'),sub(length(variables('String')),1))

    Image reference:

    10.PNG11.PNG

    There are a lot of functions in WDL function that can be used to process strings. For more details, please refer to Online doc:

    https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference

     

    Best Regards,

  • ques0buffet Profile Picture
    105 on at

    This is helpful but make sure you check if your variable has data before using the function.

     

    Example of the error you will receive:

    InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2727': 'The template language function 'take' parameters are out of range: 'count' must be a positive integer. The provided valus is '-1'. Please see https://aka.ms/logicexpressions#take for usage details.'.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard