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

Replace last letter of Variable with the next in sequence

(0) ShareShare
ReportReport
Posted on by 254

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
    254 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
    254 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,443 Super User 2025 Season 2 on at
    concat(
    	slice('XXX C0006A', 0 , -1),
    	chunk('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 1)[
    		add(indexOf('ABCDEFGHIJKLMNOPQRSTUVWXYZ', last('XXX C0006A')), 1)
    	]
    )
  • Skybluekid Profile Picture
    254 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

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard