How to Use the Append to String Variable Action in Power Automate

A team lead I worked with wanted a weekly email listing every task their team had finished. The first version of the flow used Set variable inside a loop, and the email only ever showed the last task, because each pass through the loop overwrote the one before. Switching one action fixed it: Append to string variable adds to the text instead of replacing it.

In this tutorial, I’ll explain how the action works and walk through two examples: joining a first and last name, and building a weekly task summary from a SharePoint list, including the line breaks that most tutorials forget.

Quick answer: First, add Initialize variable at the top of the flow with Type set to String. Then use Append to string variable, choose the variable in Name, and enter the text or dynamic content to add in Value. The new text goes on the end of what’s already there. Inside a loop, keep the loop running one item at a time (the default), and add a line break, such as <br> for an email, to separate items.

How Append to string variable works

Append to string variable is one of the built-in Variable actions in cloud flows. It takes two required values: Name, the string variable to add to, and Value, the text to add. The value can be typed text, dynamic content, an expression, or a mix of all three.

Append to string variable action in Power Automate with the Name and Value fields

Three rules save a lot of trouble. The variable has to exist first, so add an Initialize variable action with the type set to String. Initialize variable only works at the top level of a flow, not inside a loop, condition or scope, so put it near the trigger. And Append to string variable never adds anything on its own, not even a space, so include any separator you want in the Value.

Compared with Set variable, the difference is simple: Set variable replaces the whole value, while Append to string variable keeps the existing value and adds to the end of it. There’s also Append to array variable, which adds an item to an array instead of text to a string.

Example 1: Join a first and last name

Let’s start small. This instant flow asks for a first name and a last name and joins them into a full name.

Step 1: Create the flow with two text inputs

Create an instant cloud flow with the Manually trigger a flow trigger. Add two text inputs, First Name and Last Name.

Manually trigger a flow with First Name and Last Name text inputs

Step 2: Initialize the variable with the first name

Add Initialize variable. Set Name to varName, Type to String, and Value to First Name from the dynamic content.

Initialize variable action creating varName as a string with the First Name input

Step 3: Append a space and the last name

Add Append to string variable. Choose varName in Name. In Value, type a single space and then add Last Name from the dynamic content. That space is what keeps the result from reading “PattiFernandez”.

Append to string variable action adding a space and the Last Name to varName

Step 4: Show the result

Add a Compose action with the variable in Inputs. In the new designer, pick it from the dynamic content under Variables; the expression behind it is variables('varName').

Compose action showing the varName variable

Save the flow, select Test, and run it with a first and last name:

Run flow panel with Patti as the first name and Fernandez as the last name

The Compose output shows the full name, Patti Fernandez:

Compose output showing the full name Patti Fernandez after the append

For a single join like this, concat() in one expression does the same thing. Append to string variable really earns its place when you add text a piece at a time, such as inside a loop.

Example 2: Build a weekly summary of completed tasks

This is the team lead’s flow. Every Friday, it collects the completed tasks from a SharePoint list and emails a summary. The list is called Task Tracker and has four columns: Task ID, Task Name, Assigned To (Person) and Task Status (Choice).

SharePoint Task Tracker list with task names, assigned people and task statuses

Step 1: Create a scheduled flow

Create a scheduled cloud flow. Choose a start date and time, set Repeat every to 1 Week, and pick Friday under On these days. After creating the flow, open the Recurrence trigger and set the Time zone, for example Eastern Time, so it runs at 10:00 AM your time rather than in UTC.

Build a scheduled cloud flow dialog set to run every Friday at 10 AM

Step 2: Initialize an empty string variable

Add Initialize variable with Name set to Task Summary, Type set to String, and Value left empty.

Initialize variable action creating an empty Task Summary string variable

Step 3: Get the list items

Add the SharePoint Get items action and choose your site and the Task Tracker list. Get items returns up to 100 items by default, so for a bigger list, set Top Count under Advanced parameters or turn on pagination.

SharePoint Get items action reading the Task Tracker list

Step 4: Keep only the completed tasks

Add Filter array. Set From to the value output of Get items, and the condition to Task Status Value is equal to Completed. Because Task Status is a Choice column, compare its Value, not the column itself.

Filter array action keeping tasks where Task Status Value is equal to Completed

For larger lists, it’s more efficient to let SharePoint do the filtering with a Filter Query in Get items, such as TaskStatus eq 'Completed'. See Power Automate Get items filter query examples for the syntax.

Step 5: Append each task inside a loop

Add Apply to each and select the Body of the Filter array action:

Apply to each loop over the output of the Filter array action

Inside the loop, add Append to string variable. Choose Task Summary and build the Value from text and dynamic content: Task:, the Task Name, – Assigned To:, and the Assigned To display name. Behind the tokens, the expressions are item()?['TaskName'] and item()?['AssignedTo']?['DisplayName'].

Append to string variable adding the task name and assigned person to Task Summary

Step 6: Email the summary

After the loop, add Send an email (V2). Enter the recipients and a subject such as Weekly Completed Tasks Report, and put the Task Summary variable in the body, between a greeting and a sign-off.

Send an email V2 action with the Task Summary variable in the email body

Save and test the flow. The email arrives with every completed task, but look closely:

Weekly completed tasks email where the task lines run together without line breaks

Step 7: Add line breaks between items

All three tasks run together on one line, because nothing separates them. The email body is HTML, so the fix is to end each appended value with <br>:

Task: @{item()?['TaskName']} - Assigned To: @{item()?['AssignedTo']?['DisplayName']}<br>

Now each task appears on its own line. If you’re building plain text instead, such as a Teams message or a text file, add a real line break: press Enter at the end of the Value field in the designer.

Keep the loop running in order

Apply to each processes one item at a time by default, and that’s what you want when it changes a variable. If you turn on Concurrency control in the loop’s settings, several items run at the same time, and the appended lines can arrive out of order or get mixed up. Microsoft’s guidance is that loops that use variables must run sequentially if you need predictable results, so leave concurrency off for this pattern.

A loop-free alternative: Select and Join

For a summary like this, you can skip the variable and the loop entirely. Add a Select action that maps each filtered task to a line of text, then a Join action that joins the lines with <br>, and put the Join output in the email. It runs faster on large lists because there’s no loop, and there’s no variable to manage.

I still reach for Append to string variable when each line depends on conditions or other actions inside the loop. For more string techniques, see Power Automate string functions.

These guides cover more ways to work with variables and text in Power Automate:

Frequently Asked Questions

What is the difference between Set variable and Append to string variable?

Set variable replaces the whole value of the variable. Append to string variable keeps the current value and adds the new text to the end.

Why doesn’t Append to string variable add a space or new line?

It adds exactly what you put in Value and nothing else. Include a space, a
for HTML email, or a line break yourself.

Can I initialize a variable inside Apply to each?

No. Initialize variable only works at the top level of the flow, not inside loops, conditions or scopes. Initialize it before the loop and append inside it.

Is there a size limit for string variables in Power Automate?

Microsoft doesn’t document a maximum length for a string variable. Related limits, such as 250 variables per flow, are listed with the other rules in Microsoft’s guide to variables in Power Automate.