Remove a certain number of characters from the end of a string value or variable inside a Microsoft Power Automate Cloud Flow
A quick and simple guide by Caspar Rubin that is easy to understand and follow.
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.

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:

3. Check
When we now run the flow, we get the following result:

As you can see, the – sign and the days have been removed from the string value.
A quick and simple guide by Caspar Rubin that is easy to understand and follow on how to remove characters from the end of a string in Microsoft Power Automate Cloud Flows in 2 easy steps or how to remove a certain number of characters from the end of a string value or variable inside a Microsoft Power Automate Cloud Flow.