The Power Automate Empty function lets you check whether a given collection or string is empty or not.
In this article, I’ll introduce you to the empty function and will provide a step-by-step guide on how to use the function in a Microsoft flow.
Power Automate Empty Function
Power Automate Empty Function
Determine if a collection or string has no elements/no characters. Return True if it is empty, or False if it is not.
Syntax
empty('<collection>')
empty([<collection>])
Input parameters
- collection (mandatory): The collection/string that needs to be checked for emptiness.
Return value
- Returns true, if the collection/string is empty (has no elements/characters).
- Returns false, if the collection/string is NOT empty (has elements/characters).
Power Automate Empty Expression Examples
See some examples of empty expressions in Power Automate.
Empty expressions with collections
empty(variables('myArray')) // myArray = []
=> true
// empty check of array with one element
empty(createArray(1))
=> false
Empty expressions with strings
empty('')
=> true
empty('abc')
=> false
// empty check with one whitespace character
empty(' ')
=> false
How To Use The Power Automate Empty Function
Follow the steps to use the Power Automate Empty function in a flow.
-
Create a new flow with trigger ‘Manually trigger a flow’
New flow
-
Add a new step by clicking on ‘+ New step’
Add a new step
-
Search for ‘initialize’ and click on ‘Initialize variable’
Add Initialize variable action
-
Setup Initialize variable: 1) Provide a name, 2) select type Array, 3) Set value to ‘[]’
Setup variable
-
Add a compose step by searching for ‘compose’ and clicking on ‘Compose’
Add Compose action
-
Setup compose action: 1) click into Inputs (popup appears), 2) click on ‘Expressions’, 3) set expression to ‘empty(variables(‘myArray’))’ 4) click on ‘OK’
Setup empty expression in Power Automate
-
Save and do a test run
Result test run – Power Automate empty function example