3 Ways to Append to a String Variable in Power Automate

Do you need to append text onto an existing text string in your flow?

For example, if you’re working with a list of items that you want to store in a single string variable, appending allows you to do so without having to concatenate each item individually.

This is essential when you need to combine text data in your flows.

This post will guide you through using string variables and appending new text to them.

What Does it Mean to Append to a String?

Appending to a string means adding or joining additional text to an existing string. Essentially, you’re combining two or more pieces of text into one long text. This process is also known as concatenating strings.

In Power Automate, you can achieve this by using the Append to string variable action. First, you need to create a variable using the Initialize variable action and define it as a String data type. This is crucial since the append action will only work on string variables.

Append to String Variables with Append to String Variable Action

In Power Automate, appending a string to a variable is a straightforward process.

First, create an Initialize variable action in your flow. This will contain the original text to append to.

Give your variable a name such as myString in the Name field. Select the String option in the Type dropdown and add the initial text for your variable in the Value field.

Now when you want to append more text to the existing value of your variable, you can use the Append to string variable action.

  1. Add the Append to string variable action to your flow.
  2. Select the variable from the Name dropdown to which you want to append text. The variables you previously initialized in your flow will appear here.
  3. Add the new text to append into the Value field.

📝 Note: Add a space character at the start of the Value field if you want your text to be separated with spaces. You can also use any other characters at the start such as a comma or semicolon to create lists.

Now when you reference the variable in your flow, you will see the output combines the text!

Append to String Variables with Concat Function

Power Automate also has a function for joining text data.

This function allows you to combine two or more strings into a single one, regardless of whether the data is in a variable or not. You can use this anywhere in your flow where you need to combine string data.

concat(<text1>, <text2>)
  • <text1> is the first text value you want to join.
  • <text2> is the second text value you want to join.

For example, concat('Hello '', 'World!') will result in the text Hello World!.

concat(variables('myString'),' This is new!')

The above expression will join your variable with the text This is new!.

Using the concat function in your flow will allow you to join text to your variable while keeping the variable value unchanged.

Append to String Variables with Compose Action

Appending to a string variable can also be done using the Compose action or within any input field of your flow.

This can work the same way as the concat function without the need to create an expression.

Here is how to use the Compose action or any other input field.

  1. Add the Compose action to your flow.
  2. Add the variable or other text to which you want to append to the Inputs field.
  3. Add the text you want to append to the end of the Inputs field.

The output will combine the text from the variable with your new text! It also does not affect the original variable value.

Conclusions

Appending to a string variable is an easy process.

First, you need to initialize a variable and define its type as String. Only string variables can use the Append to string variable action.

Other methods to concatenate with your variable are available too such as the concat function or simply building the required structure using dynamic content in any input field.

How do you append to text variables? Let me know in the comments!

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Related Articles

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!