Skip to main content

Notifications

Community site session details

Community site session details

Session Id : f79ONhMocEFfe0bho9KezJ
Power Automate - Building Flows
Answered

MS Flow Variable Remove Last Character In a String

Like (0) ShareShare
ReportReport
Posted on 3 Jun 2019 20:42:08 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?  

  • ques0buffet Profile Picture
    105 on 29 Jun 2020 at 16:04:42
    Re: MS Flow Variable Remove Last Character In a String

    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.'.

  • v-bacao-msft Profile Picture
    on 04 Jun 2019 at 02:39:42
    Re: MS Flow Variable Remove Last Character In a String

    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,

  • Verified answer
    ScottShearer Profile Picture
    25,212 Most Valuable Professional on 03 Jun 2019 at 21:19:01
    Re: MS Flow Variable Remove Last Character In a String

    @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

     

     

  • Brad_Groux Profile Picture
    4,556 on 03 Jun 2019 at 21:15:40
    Re: MS Flow Variable Remove Last Character In a String

    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!

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,700 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard
Loading started