Power Automate length() Function [How to Use]

If you need to know the length of a text string in Power Automate, this is where the Power Automate length() function comes into play.

This blog post will take you to the Power Automate length() function and syntax expression. Additionally, with examples of how to use length() expression in Power Automate.

Power Automate length() Function

The Power Automate length() function is particularly useful for determining the length of a string or an array, including spaces.

If the text input is an array, it returns the number of elements (items) in the array. If the text input is a string, it returns the number of characters a string has, including spaces.

Power Automate length() function syntax

The length() function syntax in Power Automate looks like below.

length(collection: array|string)

Input Parameter:

  • Collection: This parameter can be either an array or a string. It represents the data for which you want to determine the length.

Return Value:

The function returns an integer representing the length of the input collection.

  • If the input is a string, it returns the number of characters in the string.
  • If the input is an array, it returns the number of elements (items) in the array.

This is the syntax of the length() function in Power Automate.

How to use the length() function in Power Automate

I will show you how to use the Power Automate length() function by creating an Instant cloud flow.

Example:-1 [Power Automate length() function Manually]

Text InputOutput
“Matthew Shaw,”
“Peter Siddle,”
“Mitchell Johnson,”
“Marry Christan,”
“Lidia Holloway”
5
How to use the length() function in Power Automate

To work around this, follow the steps below.

1. Create a manual trigger flow in Power Automate.

  • Navigate to https://make.powerautomate.com
  • Click on + Create
  • Select the Instant cloud flow
  • Choose trigger [Manually trigger the flow]
  • Click on Create.

2. To store the value of text during the flow, add an ‘Initialize variable‘ flow action.

  • Name: Provide a name for the variable.
  • Type: Select the type of the variable as Array.
  • Value: Here, I have given the values below.
Power Automate length() function expression

3. Add the ‘Compose’ flow action to provide the length() expression.

length(variables('TextLength'))
How to use length() function expression in Power Automate

4. Save and run the flow manually. Click Runflow.

5. The Power Automate length() expression will display the number of elements an array has, as shown below.

length() function in Power Automate

This is how to use the length() function in Power Automate.

Example:-2 [Power Automate length() function using a SharePoint List]

Here, I will demonstrate an example of the Power Automate length() function in Automated cloud flow.

For this, I have used a SharePoint List named “Employee Feedback” with a column Feedback Comment.

I want to determine the length of a text, i.e., from the SharePoint column values [Feedback Comment].

Power Automate length() function using SharePoint list

To achieve this, follow the steps below.

1. Open the Power Automate home page in your browser, click + Create -> Select the Automated cloud flow -> Provide the flow name, and choose the trigger’s flow (When an item is created or modified) -> Click on the Create button.

2. Inside the trigger, provide the required details as shown below.

  • Site Address: Provide the specific SharePoint site address.
  • List Name: Select the specific name of the SharePoint List.
How to use Power Automate length() function in SharePoint List

2. Add the ‘Get item’ flow action to retrieve a specific item from a SharePoint list.

Provide the required details.

  • Site Address: Provide the specific SharePoint site address.
  • List Name: Select the name of the SharePoint List.
  • Id: Provide the SharePoint item ID from dynamic content.
length() function expression in Power Automate

3. Next, add the ‘Initialize variable’ flow action. Ensure to give the parameters:

  • Name: Take a name for the variable.
  • Type: Select the variable datatype as String.
  • Value: I have given a ‘Feedback Comment’ from dynamic content.
Power Automate length() function format

4. Then, add the ‘Compose‘ flow action to extract the number of characters of the given string.

  • Inputs: Insert the code below with the length() expression.
length(variables('LengthOfText'))
How to get length() of a string in Power Automate

Once the flow is ready, Save and Test.

5. Create or modify an item in the SharePoint list after that. Here, I was modifying one of the SharePoint list items.

Microsoft Power Automate length() function

6. The length() of a given text will be displayed in the outputs of compose as seen in below screenshot:

Microsoft Power Automate length() expression using SharePoint List

This is how to use the length() function in Power Automate using the SharePoint list.

Conclusion

I hope you find this Power Automate tutorial helpful and understandable. Here, we have discussed the topics listed below.

  • Power Automate length() function syntax
  • How to use the length() function in Power Automate
  • Power Automate length() function using SharePoint List

Also, you may like some more Power Automate tutorials:

>