Skip to main content

How to Check Whether an Array Is Empty with empty() in Power Automate

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

A search that finds nothing returns an empty array, and the flow often needs to know that: create the list only if it isn't there yet. empty() answers with true or false. This guide uses it in a Condition.

What It Does​

Microsoft's functions reference says empty() checks whether a collection is empty: true when it is, false when it isn't. It works on text, arrays and objects:

Syntax
empty('<collection>')
empty([<collection>])

Prerequisites​

  • An action that returns an array. The example is Find the list, a SharePoint REST request in the setup flow from Part 11 of the Career Development Plan series. It asks for the lists with a given title, and its body's value array is empty when there's no such list (How to Use the body() Function).

Write the Expression​

Expression
empty(body('Find_the_list')?['value'])
Whenvalueempty(...)
The list doesn't exist yet[]true
The list existsOne itemfalse

Use It in a Condition​

Add a Condition (How to Add a Condition). In its first value, open the expression editor (How to Add an Expression), type the expression and select Add:

The If the list is missing condition's pane with the expression editor open, containing empty(body('Find_the_list')?['value'])

Leave the operator as is equal to, and set the second value to the expression true, also through the expression editor. Typed as plain text, true would be compared as the word true, not as a Boolean:

The condition with empty(...) is equal to true, both as expression tokens, and the True and False branches on the canvas

Steps in the True branch run when the list is missing, here Create the list.

Check It in a Run​

In the first run on an empty test site, the True branch ran and created RoleCompetencies. In later runs, value had the list in it, so the condition was false and Create the list was skipped:

A run with Find the list and If the list is missing succeeded, and Create the list in the True branch skipped

Common Mistakes​

MistakeWhat happensDo this instead
Typing true as text in the conditionThe comparison may never be trueAdd true as an expression
Testing the whole bodyThe body is an object with a value property, never emptyTest ?['value']
Leaving out the ?A missing property fails the stepWrite ?['value']

Troubleshooting​

SymptomLikely causeFix
The True branch never runstrue was typed as textRe-add it with the expression editor
The editor replaced true with something elseA suggestion was acceptedRetype it, then press Esc (this post)

FAQ​

Isn't length() equal to 0 the same?​

It gives the same answer for an array. empty() reads more clearly, and it works on text and objects too.

Can I put empty() straight into the condition, without is equal to?​

The new designer's Condition compares two values, so the expression goes on the left and true on the right.

Conclusion​

empty(array) is true when the array has no items. Put it in a Condition, compare it with the expression true, and the True branch runs only when the search found nothing.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.