In this tutorial, I will explain how to use the length() function in Power Automate to check the number of characters in a string or the number of items in an array.
Additionally, I will cover scenarios such as checking if a string length is greater than a certain value before triggering an action, handling cases where the length is zero (including null values), validating string length in an Instant Cloud Flow, and counting the number of items in an array.
Power Automate Length Function
The Length Function in Power Automate is a number function that tells you how many items are in a list (array) or how many characters are in a text (string).
Syntax:
length(collection: array | string)

Returns the number of elements in an array or string.
Power Automate IF Length
Now I will show examples of using the length function with an if expression.
Power Automate Expression If Length Greater Than
Let’s say you have a SharePoint list called “Employee Details” with a column “Employee Code” (Single line of text).

You want to check if the length of the Employee Code is greater than 5 before proceeding with an action (e.g., sending an email). If the length is greater than 5, send an email; otherwise, log the issue.
Now follow the below steps:
1. Create an Automated Cloud Flow using the SharePoint connector’s ‘When an item is created‘ trigger. Select the SharePoint site where your ‘Employee Details‘ list is present, and choose the ‘Employee Details‘ list.

2. Add a Condition action which will check the length of the Employee Code:
- In the left input, enter this expression:
length(triggerBody()?['EmployeeCode'])
- Set the condition as greater than.
- In the right input, enter 5.

3. In the true section, add a Send an Email (V2) action to notify the team about the new employee entry:
- To: Provide the HT Team email address.
- Subject: New Employee Added – @{triggerBody()?[‘EmployeeName/DisplayName’]}
- Body: Provide the below:
Dear HR Team,
A new employee has been added to the Employee Details list.
Employee Code: @{triggerBody()?['EmployeeCode']}
Please review and proceed with further processing.
Best Regards,
Power Automate Notification

4. In the False section, add an action to send an email to notify the admin team.
- To: Provide the Admin Team email address.
- Subject: [Issue] Invalid Employee Code – @{triggerBody()?[‘EmployeeCode’]}
- Body: Provide the below:
Dear Admin,
The following entry in the Employee Details list has an invalid Employee Code.
Employee Code: @{triggerBody()?['EmployeeCode']}
The code must be more than 5 characters. Please take corrective action.
Best Regards,
Power Automate Notification

Now save the flow, go to the SharePoint list Employee Details, and add an item that is greater than five.

After the flow runs successfully, you can see that the hr people will be notified in the Outlook group.

You can also check Power Automate Expression if the length is greater than zero.
In Power Automate, you can validate if a string has more than zero characters by using the expression if(length(YourValue) > 0, ‘Valid Length’, ‘Too Short’). This is helpful for scenarios like check minimum character limits in form submissions, filtering data before processing, or ensuring IDs and codes meet required standards.
Power Automate IF Length is Zero
You have a SharePoint list called “Customer Requests”, with a column “Customer Email” (Single line of text). Before sending an email confirmation, check if the Customer Email field is empty (length is 0).
- If the field is empty (length = 0): Email the admin about the missing email.
- If the field is not empty: Proceed with sending the confirmation email to the customer.
To do this, follow the below steps:
1. Created an Automated Cloud flow with the trigger “When an item is created or modified” for the Customer Requests SharePoint list.

2. Add a Condition action and provide the below parameters:
- In the left input, enter this expression:
length(triggerBody()?['CustomerEmail'])
- Set the condition as equals 0.

3. In the true section, add a “Send an Email (V2)” action to notify the admin.
- To: Provide the Admin Team email address.
- Subject: [Issue] Missing Customer Email
- Body: Provide the below:
Dear Admin,
A new customer request was created without an email.
Request ID: @{triggerBody()?['RequestID']}
Please update the record with the correct email.
Best Regards,
Power Automate Notification

4. In the False section, add a “Send an Email (V2)” action to send a confirmation email to the customer.
- To: Provide the customer email column from dynamic content.
- Subject: Confirmation of Your Request
- Body: Provide the below:
Dear Customer,
Thank you for your request. Our team will get back to you shortly.
Best Regards,
Customer Support Team

Now save the flow, go to the SharePoint list Customer Requests, and do not add the Customer Email.

After that, when we see the flow history, you can see we will face an error:
[Error] The template language function ‘length’ expects its parameter to be an array or a string. The provided value is of type ‘Null’ in Power Automate
Action 'Condition' failed: Unable to process template language expressions for action 'Condition' at line '0' and column '0': 'The template language function 'length' expects its parameter to be an array or a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#length for usage details.'.

The error occurs because length() expects a string or array, but CustomerEmail is null (empty).
[Solution] The template language function ‘length’ expects its parameter to be an array or a string. The provided value is of type ‘Null’
Before checking the length, use the coalesce() function to handle null values. This function replaces null with an empty string (''), ensuring length() always receives a valid input.
length(coalesce(triggerBody()?['CustomerEmail'], ''))

After making the changes, save the flow and either add the same item again or manually re-trigger the flow. The admin team will receive an email when the flow runs successfully because the Customer Email length is zero.

Power Automate Length of String
You want to create an Instant Cloud Flow that takes a string as input, checks its length, and performs different actions based on the length.
- If the length is greater than 10, send an email notification.
- If the length is 10 or less, send a Teams message.
To do this, follow the below steps:
1. Go to Power Automate -> click Create -> Choose Instant Cloud Flow. Select Manually trigger a flow. Click + Add an input > Choose Text.
- Name: Input String

2. Add a Condition to Check the Length.
- In the left field, enter:
length(triggerBody()?['text'])
- Operator: is greater than
- Right field: 10

3. Click Add an action inside the True section, add an Send an Email (V2):
- To: Provide the Admin Team email address.
- Subject: String Length Exceeded
- Body: Provide the below:
Dear Admin,
The input string exceeds 10 characters.
Input: @{triggerBody()?['text']}
Length: @{length(coalesce(triggerBody()?['text'], ''))}
Best Regards,
Power Automate
4. Click Add an action inside the False section, add a Post a message in a chat or channel action from (Microsoft Teams):
- Post as: Flow bot
- Post in: Channel
- Team: AdminGroup
- Channel: General
- Message:
The input string is within the allowed length.
Input: @{triggerBody()?['text']}
Length: @{length(coalesce(triggerBody()?['text'], ''))}

Now save the flow and run it manually, then provide the Input string and run the flow.

After the flow runs successfully, you can see the message in Microsoft Teams.

Power Automate Length of Array
In this example, I will create an Instant Cloud Flow, and then we will check the length of an array.
1. Create a new Instant Cloud Flow and choose Manually trigger a flow as the trigger.

2. Add an Initialize variable and provide the below parameters:
- Name: varPowerPlatform
- Type: Array
- Value:
["Power Apps", "Power Automate", "Power BI", "Power Pages", "Copilot Studio"]

3. Now add compose action and provide the below parameters to check the length of the array:
length(variables('varPowerPlatform'))

Now, save the flow and run it manually. After the flow runs successfully, click on the Compose action, and you will see the length of the array.

Then, based on the length, you can add another action to handle different cases. For example:
- If the array length exceeds a certain number, trigger an approval request or create a report.
- If the string length is more than 10, send an email notification to the admin.
- If the string length is 10 or less, post a message in Microsoft Teams.
Conclusion
This tutorial covered the length() function in Power Automate, demonstrating how to check the number of characters in a string or the number of elements in an array. We explored practical scenarios, including validating the length of an Employee Code in a SharePoint list before sending an email, checking if a Customer Email is empty, and handling null values using coalesce().
Additionally, we looked at length-based conditions in an Instant Cloud Flow to trigger different actions, such as sending an email or posting a Teams message. Finally, we checked the length of an array to understand how many items it contains.
You may also like:
- Check If the Filename Contains in Power Automate
- Power Automate Condition If String
- Check IF SharePoint List is Empty in Power Automate
- Check if SharePoint List Already Exists in Power Automate
- Send Email Reminders From a SharePoint List Using Power Automate
- Check if a file exists in the SharePoint document library in Power Automate

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.