Building strings is one of the most common actions in any tool or framework, and Power Automate is not the exception. The Concat function helps us build from different pieces of data a string of data. I’ve written many articles that use this function for tasks like building messages to display to the user, combining information to generate JSON files, and more. So let’s explore a bit further.
Usage of the concat function
It follows a simple pattern where you provide one or more values, and they are combined into a string. Notice that I say “values” and not strings.
Let’s start with a simple example:
concat('Manuel', ' T ', 'Gomes') will return Manuel T Gomes
What about other types? Let’s use a variable “Test” with a boolean type:
concat('The result is: ', variables('TEST')) will return The result is: False
Integer and Floats
Let’s try a few more. Same as above but for “Integer” values.
TEST variable is equal to 12 concat('The result is: ', variables('TEST')) will return The result is: 12
How about “Float” values?
TEST variable is equal to 12.5 concat('The result is: ', variables('TEST')) will return The result is: 12.5
Now a tricky one. An array. We’ll use the same variable, and we’ll build the array using the “createArray function.”
With this, the variable will be initialized with an array that we can use to test.
concat('The result is: ', variables('TEST')) will return The result is: ["Manuel","Teixeira","Gomes"]
It’s not the nicest way to display a set of values. If you want to combine the values of an array, I would recommend using the “join function.” You only need to pass the array and the separator. For example:
join(variables('TEST'),' ') will return Manuel Teixeira Gomes
Microsoft provides some warnings regarding “base64”. Although the encoding and decoding are automatic, the concat function may return some incorrect values. Be careful in this case, or avoid it as much you can. You’ll rarely need to do a concatenation in this case, but if you do be sure to test it to get the correct results and deal with errors.
Also, there’s no documented limit for concatenations but keep it as low as possible. Having huge concatenations will make your life a lot harder debugging when something goes wrong.
Here are some things to keep in mind.
Concatenations will aggregate exactly what you provide to the function. So if you want spaces, for example, you need to add them yourself. It’s quite a common mistake so consider this.
Don’t use the concat function on arrays. You can, but the result is rarely what you want. As mentioned before, use the “join function” to get nicer results.
Data types other than strings
As you saw before, the conventions are automatic, but you may get less than optimal results. For example, for a Boolean variable, you’ll get “False.” Rarely, we won’t show it that way—either “Yes/No” or in lowercase, for example. Automatic conversions are great but can be a problem. Another example is the Float data type. You may want to display to the user “3.14,” for example, but if you don’t do any conversion, you’ll get “3.141592653589,” which is not quite as user-friendly as the first one.
The idea is always to control what you’ll get, so be careful with other data types than stings where you don’t have 100% control over what you’ll get in the end.
Break it down
I would not go over 20 parameters in a concat function. 20 is not a defined limitation, but further than that, you’ll have a hard time debugging it. If necessary, build several smaller concatenations and combine them in the end. This will give you a view in each “section” and see if everything is as expected.
You may be tempted to nest concat functions, because it will provide you with only one function that takes care of the full string. But as always, you’ll have a hard time debugging it. Break it down into smaller chunks that you can digest and analyze if something goes wrong.
I always prefer to add more actions with smaller parts than having only one huge formula. Combine them with a “scope action,” making things simpler and more organized.
Please note that formulas may have localization-based differences. For example, you should write “concat” with “,” separating each of the arguments, but if your regional settings are set to Portugal, you should use “;” instead.
Back to the Power Automate Function Reference.