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
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 in 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 function

The expression used is:
replace(replace(formatNumber(0,Concat('C',triggerBody()['number'])),'$0.',''),'0',triggerBody()['text'])Ok, that needs a bit of explaining.
formatNumber
I’m first having a look at the format number function:
formatNumber(0,Concat('C',triggerBody()['number']))
The format number function is going to generate us smoothing like this:
$0.00000
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.
formatNumber(0,'C5')
Replace functions
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.

Limitations
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.
Frequently asked questions
How does the example repeat text in one Compose action?
It formats zero with a precision derived from the repeat count, removes the currency prefix and replaces the resulting zero characters with the input text.
What limitation should I consider?
The article notes that this format-based technique has a precision limit, so larger repeat counts may need another approach. Check current formatting behavior and test the input range.

