Do you want to know about the Length function in Power Automate? In this Power Automate tutorial, I will explain how to use the Len() function in Power Automate with examples.
Length function Power Automate is used to count the number of characters in a string or to find the length of an array.
Here, I will show you two examples of how to get string length in Power Automate by using the len() function.
Power Automate Len() Function
Microsoft Power Automate provides many string functions to perform various string operations. Among them, the LEN() function plays a role in Power Automate flow to find the length of a string or to check the length of an array.
The Power Automate LEN() function will return the length of a text string, which means the number of characters the string consists of. It also includes spaces as characters in it. It returns output as an integer that represents characters in a given string.
Syntax of Power Automate LEN() Function
This is the syntax that has to be used in a Power Automate flow for the LEN() function.
Ex: length(‘xyz’) => Returns the output as ‘3’ because the ‘xyz’ string has three characters.
Note:Power Automate length(LEN) function does not work when checking the length of numbers. For that, it should have to be converted into a string by using a string function. Ex: length(string(56789)) => Returns output as ‘5’
LEN() Function Examples in Power Automate
Here, I will show you two examples, one of which will trigger manually and calculate the length of a string in Power Automate. In the other example, the flow will trigger when an item is created or modified in a SharePoint list.
Let’s implement it in a Power Automate flow by creating an “Instant cloud flow” that will trigger manually.
In the first example, I will show you how to create an instant cloud flow in Power Automate that will trigger manually to get string length in Power Automate. Follow the below steps.
Here, I will explain the Power Automate LEN() Function using a manual trigger flow.
1. Navigate to make.powerautomate.com in the browser to open a Power Automate page. Click on “+Create” -> Select “Instant cloud flow”.In the next window, Give the flow name, Select “Manually trigger a flow” and click on Create.
- Add a text box to provide input value to the trigger.
2. In the next step, add an “Initialize variable” flow action to store the text string value. Set the details below:
- Name: Add a name for an initialized variable
- Type: Select the datatype as ‘String’
- Value: Take text value from the dynamic content.
3. Then, add the “Compose” data operation to provide a length expression and see the output of a string.
- Inputs: Add value generated from the initialized variable with length expression.
4. Now, it’s time to save and test the flow. Click on Save. Test it Manually.
5. Observe the outputs of the compose flow action, which will display the length of characters of a string as shown below.
This is how to use the Power Automate LEN function to calculate the length of a string in a flow.
Now, I will discuss another example of the Power Automate length function using a SharePoint list.
Recently, we have been working on a project based on Power Automate string functions, where the client requires us to check the length of a text column in a SharePoint list.
To do that, I have used a SharePoint list named “New Admissions List” with different columns, as presented in the table below.
|Admission ID||It is a single line of text – Title column|
|Full Name||Single line of text|
|Department Head||Person or Group field|
Here, we wanted to check the length of a text column “Admission ID” that varies in size or length of a string.
Let’s build a Power Automate flow that will trigger automatically and will use a SharePoint list.
Follow the below steps to implement the Power Automate LEN() function inside a flow.
1. Open a Power Automate home page, click on +Create -> Select “Automated cloud flow” -> provide flow name, choose a trigger ” When an item is created or modified” -> Click on Create. Set details below in a trigger.
- Site Address: Select a specific list name from a drop-down.
- List Name: Choose a SharePoint list name from the drop-down.
2. After that, add an “Initialize variable” to store the values of a text column. Set the details below in the variable.
- Name: Provide the name for a variable.
- Type: Select datatype by clicking on drop-down.
- Value: Take the SharePoint list column from dynamic content.
3. Finally, add the ” Compose” data operation to provide length expression along with the variable.
- Inputs: Add the below-given value in the inputs.
4. Now, the flow is ready to save and test. So, click on Save and then Test it. Test the flow Manually.
5. Now add an item to the SharePoint list; the outputs of the ‘compose’ flow action will return the length of characters in a string type i.e., Admission ID.
This is how to find out the length of characters in a text string with the LEN function by using Power Automate.
I hope you understand how to use the Power Automate len() function to calculate the length of a string. We saw how to trigger a flow manually to get the length of a string in Power Automate. I have also shown how to get the length of a string in a SharePoint list in Power Automate.
You may also like:
- Power Automate startswith Function
- Power Automate LastindexOf() Function
- Power Automate IndexOf() Function
- Power Automate toLower() Function
Bijay Kumar Sahoo is a highly accomplished professional with over 15 years of experience in the field of SharePoint and related technologies. He has been recognized as a Microsoft MVP (Most Valuable Professional) more than 9 times, starting from April 2014, for his exceptional contributions to the SharePoint community. Bijay is also a prolific author, having written two books on SharePoint – “Microsoft Power Platform – A Deep Dive” and “SharePoint Online Modern Experience Practical Guide“. His deep insights into SharePoint are also shared on his popular YouTube channel EnjoySharePoint where he teaches SharePoint to a global audience (From various countries like the United States of America, Canada, the United Kingdom, Australia, New Zealand, etc). Read more…