Categories
Guides Microsoft Flow Power Automate Power Platform

Remove Characters

How to remove a certain number of characters from the end of a string value in Microsoft Power Automate (Flow).

A quick guide on how to quickly cut characters from a string value in a Flow.

1. Initial Situation

Let’s say we have a dynamic content string value where we want to remove the last three characters.
An example for this would be a date where we don’t want the days, only year and months.

Example “Compose” action

So basically turn this:

2022-09-06

in to:

2022-09

To do this, we need to remove -06 from the first string.

2. Expression

The Expression we use, to get rid of a certain amount of characters at the end of a string is the following:

substring(STRING,0,sub(length(STRING),3))

Let’s replace STRING in the above Expression with our dynamic content from the flow.

In our case, that’s the Compose – Date action.

substring(outputs('Compose'),0,sub(length(outputs('Compose')),3))

If you want to remove, let’s say, 5 characters instead of only 3, just change the number 3 at the end of the Expression to 5. Like this:

substring(outputs('Compose'),0,sub(length(outputs('Compose')),5))

The flow now looks like this:

Don’t forget to add the formula as an Expression!

Check

When we now run the flow, we get the following result:

Check – we successfully cut the -06 from the string value

As you can see, the sign and the days have been removed from the string value.