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 / Replace last letter of...
Power Automate
Answered

Replace last letter of Variable with the next in sequence

(0) ShareShare
ReportReport
Posted on by 262

Hi,

 

I am curious. I have a variable XXX C0006A.  Is it possible to resubmit the variable and change the A to B, XXX C0006B in a flow?

 

Then Change to a C if required.

Categories:
I have the same question (0)
  • fchopo Profile Picture
    8,003 Moderator on at

    Hi @Skybluekid 

    You could use the following expression:

    replace(outputs('compose'),last(outputs('compose')),'B')

    compose.png

     Hope that helps!

    Ferran

  • Skybluekid Profile Picture
    262 on at

    Hi @fchopo 

    thank you for the reply.  I was thinking more changing the letter dynamically i.e. if the variable contains XXX C0006A, then it would automatically change to XXX C0006B, without any hardcoding.

  • grantjenkins Profile Picture
    11,063 Moderator on at

    A few questions.

    1. What do you do with XXX C0006Z - what should it change to?
    2. Will the variable always be in the same format? Will it always be the last letter you need to change?

    Below is one way to do it.

     

    See full flow below. I'll go into each of the actions. Note that they are all Compose action - I've just renamed them.

    grantjenkins_0-1698674460078.png

     

    The expression I used in the Output is:

    concat(
     substring(outputs('Input'), 0, sub(length(outputs('Input')), 1)), 
     substring(outputs('AZ'), add(indexOf(outputs('AZ'), last(outputs('Input'))), 1), 1)
    )

     

    Note that in AZ I added A at the end so if the code ends with Z it will be set as A. Not sure what you would want to do in your scenario.

  • Skybluekid Profile Picture
    262 on at

    Hi @grantjenkins 

     

    Thank you for the reply.  I would not anticipate that it would get to Z, in the case of the actual flow.  I will give this a try.

  • Verified answer
    Chriddle Profile Picture
    8,525 Super User 2026 Season 1 on at
    concat(
    	slice('XXX C0006A', 0 , -1),
    	chunk('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 1)[
    		add(indexOf('ABCDEFGHIJKLMNOPQRSTUVWXYZ', last('XXX C0006A')), 1)
    	]
    )
  • Skybluekid Profile Picture
    262 on at

    Thank you both for the assistance

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 86 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 55

#3
Ellis Karim Profile Picture

Ellis Karim 53 Super User 2026 Season 1

Last 30 days Overall leaderboard