Data Types

Power Apps Canvas - Solutions

The Power Platform is an amazing application platform and is aimed at low-code and no-code individuals, while also providing the opportunity to provide additional support for those with a pro-code background. However, if you’re starting out in the industry with no-code and even a low-code background, being exposed to variables, collections, parameters, parallelism etc can be a little daunting. Have no fear, I’m here to help with this! #PowerWhat #LessCodeMorePower

Let’s look at Data Types! So, we want to understand what variables, functions and more are and how to use them, but first we need to look at how data is stored and what exactly the different ‘types’ of data are. This post will primarily be looking at basic data types with a more ‘advanced’ post being published at a later date.

Let’s begin by looking at the data types you can store in a variable. Now, at this point you might be thinking, well Joe, I do not know what a variable is! That’s OK! we’re just looking at the dropdown for the data types list and should not focus too heavily on the variable aspect at this moment in time. We will then look at how these are represented in the Power Platform.

As you can see from the image above, there are currently six data types that can be assigned to a variable in Power Automate. We’re going to focus on the first four as the ‘base’ data types as we will need to understand variables and more to understand Objects and Arrays, this would come at a later date.

Boolean

The Boolean data type, often referred to as a ‘Bool’, is a type of data that has one of two possible values intended to represent the two logical truths of True or False. Therefore, when looking at a ‘boolean’ data type you can consider this a True/False data type. For example, does ‘FlowJoe’ contain the character ‘J’, the boolean answer would be ‘True’. ‘J’ is represented within the name ‘FlowJoe’. We can then use a true and false value and react accordingly in, for example, a Flow condition.

Integer

The data type of the Integer, more commonly known as an ‘Int’, is a data type representing an entire number (not a fraction) that can be positive, negative, or zero. The numbers -100, -10, 0, 10, 100, and 10,999 are therefore all integer numbers. Unlike floating point numbers (Float’s that we will be discussing momentarily), integer numbers cannot have decimal places. These are great for cycling through data in a loop or counting a class attendance but they’re not good for monetary transactions as you will lose all those vital decimal numbers representing pennies/cents etc.

Float

Integers and floats are two separate numerical data types. Unlike the previously discussed Integer that represents a number that has no decimal point. A float, also known as a floating-point-number, is a number of floating-points which means that it is a number with a decimal place. Floats are used when greater precision is required, using our example, if we were using currency and wanted to store $10.50 we could not do this as an Int, as it would not display the 50c, we would need to use a Float to store the whole numerical value including the decimal place.

String

The data type of a string is a type of data used to represent text. This consists of a set of characters which can contain spaces, numbers “FlowJoe” and “I love Power Automate!!11!” are both strings as well as “2020” providing you use specify that the numbers are representing a string and that you’re using quotation marks around the characters. This is important! Remember “” = String!

Power Automate

When using data types in Power Automate, a good way to get started is by using variables. Now, as we mentioned before, we have not discussed these yet, but if you open a flow and add an action of ‘Initialize Variable’ you will be able to at-least get started with looking at basic data types.

Boolean

The example I’ve used below is to show that I cannot assign a string of “test” to a boolean (true/false).

An error is thrown telling you that you have done something wrong, this is a great way to see what happens when different data types conflict.

Now, below is the correct way to assign ‘true’ to a boolean;

You simply type ‘true’ with no quotation marks, setting the boolean to a true value. You can do the same with false here too.

Float

Again, with Float I’m expecting a number representing 1.0, but I have put quotation marks around “1.0” as the example shows below which changes the numerical value to a string and throws an error;

You must simply pass the decimal value in without the quotation marks to set the correct floating point value shown below:

Power Apps

Let’s take a look at how these differ in Power Apps. Unlike PowerAutomate, within Canvas PowerApps you do not specify a data type, the information you set on a variable will detect the data type you’re passing through and set it.

String

For example, I’ve created a button to set a variable of a string “test”, to do this I use the Set functionality, provide a variable name and then passing through “test”. I’ve not specified anywhere that it is a string, however, as I’m using the quotation marks, I’m expected PowerApps to understand this and set the type for me.

Once pressed the variable is set, so I can then click on the View > Variables section to see how the variable is represented in PowerApps.

You can see the variable type is ‘Text’ and we have stored “Test”. Again, don’t worry if you do not understand variables yet, that’s in the next session, we just want to see the data types represented. Let’s have a look at a boolean in PowerApps.

Boolean

We have changed the data passed through to ‘true’ without quotation marks, when we click the button we are expecting a Boolean value of true to be represented in the variable:

Now let’s look at the stored value:

You can see a ‘Boolean’ type has been used!

Summary

That’s basic data types, now you know how data can be represented in four separate ways. We will be moving on to variables next time and you will then understand the storage and data representations easier after this post!

Stay tuned!