Pad with zeros or spaces
With Power Automate Desktop, you can do much of what you want just by dragging and dropping actions, but when you try to process the data you get, even a little, things don’t always go the way you want.
This article explains how to pad text data with zeros or spaces.
Implement by copying and pasting
Section titled “Implement by copying and pasting”Copy the following code and paste it into the Power Automate Desktop flow designer to add the actions.
The first line pads the beginning of a number with zeros, and the second line pads the end of a string with spaces.
Text.Pad Text: 103 PadPosition: Text.PadPosition.Left PaddingText: 0 TotalLength: 10 PaddedText=> PaddedNumberText.Pad Text: $'''%'apple'%''' PadPosition: Text.PadPosition.Right PaddingText: $''' ''' TotalLength: 10 PaddedText=> PaddedTextImplement in Power Automate Desktop
Section titled “Implement in Power Automate Desktop”-
In “Search actions”, type “Pad text” and set the parameters as follows. The first and third parameters have similar names: “Text to pad” is the data to pad, and “Text for padding” is the character to pad with (“0” for zero padding).
Parameter Value Text to pad The target string or variable Pad Choose whether to pad on the left or the right Text for padding The character used to fill the missing length Total length The total number of characters after padding -
When you run the flow, the action returns the text padded with the specified character until it reaches the total length. For example, padding “103” with zeros to a total length of 10 produces “0000000103”.