Data Types in Power Automate

Power Automate is very rigid with its data types, and it can be a little confusing for those users that do not have an IT or Data Analytics background. The concept revolves around ensuring that specific data matches predefined types. It basically means that, if Power Automate is expecting a number, you cannot provide a text, as these values have different data types.

In this post you will understand what are data types and how to work with them.

What is a Data Type?

Data type is a way of classifying and organizing different kinds of data in computer programming. They are like containers, where each data type has a specific shape and size, and it can hold specific types of things.

As example, an “integer” data type holds whole numbers like 5 or -10, while a “string” data type holds text like “Microsoft” or “Power Automate.” Using the wrong data type can result in errors, and a lot of flows fails due the misunderstanding on data types. For instance, if a variable intended to store a person’s age is defined as a string instead of an integer, the user will receive an error if attempt to perform any arithmetic operations, like addition or subtraction.

Which are the available data types in Power Automate?

In Power Automate, the data types are generally similar to those found in programming languages and productivity software, like MS Excel or Power BI. Currently, Power Automate contains the following data types:

String

A sequence of characters, typically used for text data. To identify a string value, it is necessary to surround it with quotes. Some examples of values of string data type are ”John Smith”, “1234” (between quotes), “abcdef”, “Power Automate”, and even much larger texts, like the body of an email, the content of a contract or a report of hundreds of pages.

When using strings inside expressions, make sure to use single quotes. Different from other tools, Power Automate does not recognize, for strings, the double quotes. For example, in this expression used to join two texts (to learn more about expressions, refer to this article), both texts may be surrounded by single quotes:

expression pane in power automate

When you are initializing a variable, however, you will not need the quotes and can simply enter the text.

Integer

A whole number without a decimal point. For example, an integer data type could store a person’s age, like 30; a quantity of units sold, like 8741; a difference between two dates, like -35, and so on.

Float

A data type for numbers with decimals. For example, a float data type could store a person’s weight, like 65.5 kilograms; or a product price, like 19.99.

You can assign an integer value to a float variable without returning any errors.

Boolean

A data type that represents true or false values, only. It is a binary type very used for conditional actions. For example, a boolean data type could indicate whether an email contains attachments or not, with “true” for yes and “false” for no.

When represented inside expressions, it is not needed to include single quotes, as this is not a value with string type.

Array

A data type that can hold multiple values in a single variable. It is a list. For example, an array data type could store a list of numbers, like [1, 2, 3, 4, 5]; a list of strings representing emails, like [“john@smith.com”, “raphael@digitalmill.net”, “info@gmail.com”]; or even a list with random values and different data types, like [“Power Automate”, 123.3, true, 58].

When initializing an array variable, you need to surround the array items with brackets. There are several strategies to access the elements from an array, and you can learn about them in this article.

Object

A data type that can hold multiple values of different types and is used to store structured data. For example, an object data type could store information about a person, like { “name”: “Alice”, “age”: 25, “city”: “New York” }.

All Power Automate operations are restricted to these data types, even the most complex tasks. That’s why it is very important to understand each data type use and limitations. 

Is date/time a data type in Power Automate?

Date and time play a significant role in Power Automate flows, with certain expressions requiring a “timestamp” as a parameter. Surprisingly, there is no dedicated data type for dates; instead, a timestamp is treated as a string, but following a specific format. To learn more on how to work with date/time in Power Automate, check this article.

Objects in Power Automate

Objects, though initially confusing, are entities that store key-value pairs. Each key is a unique identifier, and each value represents associated data. Keys must be strings (in objects context, all strings must be enclosed in double quotes), while values can be of any data type, even other objects or arrays. Objects are enclosed in curly brackets (“{}”), with the key-value pairs separated by commas.

This is an example of an object, which represents an user with its id (integer data type), its name (string data type) and if it is active or not (Boolean data type):

object in power automate

The keys (property names) are highlighted in green, while the values are highlighted in yellow. All keys are necessarily strings, while the values can have different data types. To relate a key to a value, you need to use the “:”.

For further learning on how to work with objects, refer to this article.

Converting numbers to strings in Power Automate

It is possible to store numbers in a text variable, but it comes with limitations. Power Automate won’t allow any arithmetic operations with such values.

Even when variables have the same value but different data types, Power Automate considers them “not equal.” For instance, initializing two variables with the value 123, one as an integer (highlighted in yellow) and the other as a string (highlighted in green), will result in them being considered different. This behavior is essential to keep in mind when using conditions in Power Automate. For more insights on handling conditions, check out this article.

Here we have an example of this difference when using conditions:

numeric and text variables in power automate

When running the flow, the condition will return false, as “123” (string) is different from 123 (integer).

condition result in power automate

When converting a number into a string, Power Automate usually is very flexible. For example, it is perfectly possible to perform the following operation, when we are inserting a numeric variable as dynamic content to a string variable.

concatenating text and numbers in power automate

It just concatenates both values, forming a single string:

output in power automate

This logic can be used within expressions too, and this is a very useful strategy whenever you are working with text operations in Power Automate.

Typically, when using numbers where a string is expected, Power Automate automatically performs the conversion. However, there is an expression that makes this conversion explicitly: the string() expression. This expression is relevant when we are working with comparisons, like we did in a previous example. If we take the same ‘Condition’ that we used but now inserting the ‘numeric’ variable inside a string() expression, the result will return true, as now the action will be comparing ‘123’ with ‘123’.

string expression in power automate
condition output in power automate

The same logic can be used for floats and booleans, just inserting these values inside the string() expression.

Converting strings to numbers in Power Automate

We can simply assign numbers (or a numeric variable) to a string without any transformations. However, the reverse is not true. Attempting to assign a string variable to a numeric one (highlighted in green and yellow) will result in an error, even if the string content can be converted into numbers:

convert string to number in power automate

This is the result after running the flow:

type error in power automate

The solution here is simple: we just need to use the int() expression (in the same way that we used the string() expression before) to convert a text into an integer:

int expression in power automate

Then the action runs fine, without any errors:

successful output in power automate

The same logic can be used for transforming strings in floats, by just using the float() expression.

Converting strings to arrays in Power Automate

Arrays are lists, and you can easily transform strings into arrays using the split() expression. This expression requires two parameters: the text to be split and the separator to be used for the operation.

In the example below, we initialize a string variable called ‘names’ and store 5 names separated by comma (highlighted in green). Then we initialize a new variable (at this time an array) called ‘names_list’, and assign to it an expression (highlighted in yellow), which will contains the split(), and its first parameter is the dynamic content from ‘names’ variable (highlighted in blue) and the second one is a string of a comma (highlighted in pink, pay attention that we are using single quotes), as this symbol will be used as separator.

split expression in power automate

After run the flow, the values will be transformed in an array (notice the brackets in the outputs of the array variable). 

string to array in power automate

You can use any separator in this operation. For example, your text can use ‘8’ as separator or a word or even a sentence: as long as you are using a string as separators, anything is accepted.

split array in power automate

A very frequent use case for transforming strings into arrays is the text extraction from emails, and its insertion into documents. In this article you can find a step-by-step on how to use expressions in Power Automate to extract data from emails and populate an Excel table with it.

Converting arrays to strings in Power Automate

Now, let’s reverse the process and convert the output of the previous example (a list of names in an array) back into a string. The process is very similar, but now we will be using a join() expression and set the separator that will be used inside the new string to separate each value. The order of the parameters remains the same as the split() expression: first the array to be joined (highlighted in blue) and then the separator (highlighted in green, in our case, it will be a dash):

join expression in power automate

After running the flow, this is the result:

join output in power automate

Conclusion

Understanding data types can greatly enhance one’s proficiency in building flows with Power Automate. A lot of errors can be prevented by just understanding which is the expected data type and how to get it.

By Raphael Zaneti

Power Platform Developer