How to Check If Array is Empty in Power Automate [Using 3 Functions]

Last week, I worked for a client who needed to process API responses in Power Automate. The challenge? Sometimes, the API would return an empty body, and the flow required to handle it gracefully without breaking. If you have ever encountered this issue, you know how frustrating it can be when your flow fails because the response is empty.

We can check if the array is empty in Power Automate to avoid this. In this tutorial, I will show you three different ways to do this:

  • Using the Power Automate empty() Function with a Condition Action
  • Using the Power Automate length() Function with a Condition Action
  • Check for an Empty Array with the First Index in Power Automate

Different Methods to Check If an Array Is Empty in Power Automate

Here, we will check if an array is empty in Microsoft Power Automate. I will cover two standard methods: using the empty() function and the length() function.

Using empty() Function [with a Condition Action]

This method checks if the array is empty using the empty() function. Now, follow the below steps:

1. Go to Power Automate -> + Create -> Instant cloud flow -> Name it “Check Empty Array” -> Select Manually trigger a flow -> Create.

power automate condition if array is empty

2. Add the Initialize variable and provide the below parameters:

  • Name: myArray.
  • Type: Array.
  • Value: [] (empty).
Power Automate Checking if an array is empty

3. Add a Condition Action and provide the below:

  • Left side: empty(variables(‘myArray’)) (use the “Expression” tab).
  • Operator: is equal to.
  • Right side: true (type in “Expression” tab).
power automate empty array variable

4. In the true section, add a compose prover the value as Array is empty. In the same way, in the False section, add a Compose action and provide the value as Array is not empty.

Using the empty() Function with a Condition Action Power Automate

Save and run the flow. After the flow runs successfully, you can see the true part will run because our array variable is empty.

check if filter array is empty power automate

Using length() Function [With a Condition Action]

This method uses the length() function to check if the array has zero elements. To do this, follow the below steps:

1. Same as above: Instant cloud flow -> “Check Empty Array” -> Manually trigger a flow.

power automate condition if array is empty

2. Add the Initialize variable action and provide the below parameter:

  • Name: myArray.
  • Type: Array.
  • Value: [1, 2, 3] (non-empty).
power automate array if not empty expression

3. Add a Condition Action and provide the below:

  • Left side: length(variables(‘myArray’)) (use the “Expression” tab).
  • Operator: is equal to.
  • Right side: 0 (as a value).
How to set up a Condition in Power Automate flow to check if array

4. In the ‘True’ section, add a Compose action with the value Array is empty. Similarly, in the ‘False’ section, add a Compose action with the value Array is not empty.

Using the empty() Function with a Condition Action Power Automate

Save and run the flow. Once the flow executes successfully, you will see that the ‘False’ section runs because the array variable is not empty.

Ways to Check If an Array is Empty in Power Automate

Check for an Empty Array with the First Index in Power Automate

Suppose you have a Power Automate flow that receives an array of items (e.g., a list of names). Before proceeding, you want to check if the array is empty.

To do this, follow the below steps:

1. Go to Power Automate -> Click + Create -> Instant Cloud Flow -> Name your flow (Check Empty Array) and select Manually trigger a flow as the trigger -> Click Create.

power automate condition if array is empty

2. Add a new action Initialize variable action and provide the below parameter:

  • Name: myArray
  • Type: Array
  • Value: For testing non-empty arrays like [“Alice”, “Bob”, “Charlie”].
Check for an Empty Array with the First Index Power Automate

3. Add a Condition to check the First Index and provide the below parameter:

  • First field: variables(‘myArray’)?[0]

(This expression checks the first element of myArray. The? ensures no error if the array is empty, returning null instead.)

  • Operator: is equal to
  • Second field: null (type this directly or use the expression null).

This condition checks if the first index ([0]) is null, which happens when the array is empty.

Power Automate Check for an Empty Array with the First Index

4. In the ‘True’ section, add a Compose action with the value ‘The array is empty‘. In the same way, in the False section, add a Compose action and provide the value as “The array has items: @{join(variables(‘myArray’),’,’)}.”

How to Check If the Array is Empty in Power Automate

Click Save, then Test -> Manually. After the flow runs successfully, the false part will run.

Check If the Array is Empty in Power Automate

Conclusion

In this tutorial, we explored three ways to check if an array is empty in Power Automate. We used the empty() function to determine if an array has no elements, the length() function to check if the array’s size is zero, and the first index method to verify if the first element exists.

You may also like:

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App