Today I was asked on the chat about how to create a REPT function in Power Automate. Excel has a REPT function to repeat the same text a specified number of times. Howe to do this in Power Automate.
The REPT Function
Table of Contents
In Excel you can use REPT(“Text”, 3) and then you will get “TextTextText” as a result. Within Power Automate this is a bit harder, but we can do this ion one single action.
The Power Automate REPT() equivalent
First of all I’m going to add a trigger that takes two parameters. My text and the repeat count can then be supplied.
Then we need just one Compose action that gives us the REPT fucntion
The expression used is:
Ok, that needs a bit of explaining.
I’m first having a look at the format number fucntion:
The format number function is going to generate us smoothing like this:
For more information on the format strings please have a look at the Microsoft documentation for number formatting.
In our case if we set the number to 5 we will construct the number format C5 which stands for currency with 5 digits after the dot.
Then we have two replace functions. First we are replacing the “$0.” with nothing. before we replace every 0 with the text that we want to repeat.
The formatNumber has C99 as a maximum limitation. So this method will only work for up to 100 repeats. For any larger numbers we might have to do some looping around in our flows.