Power Automate Empty Function Explained

Power Automate Empty Function

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
empty expression in Power Automate

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.

  1. Create a new flow with trigger ‘Manually trigger a flow’

    Power Automate Empty Function new flow

    New flow

  2. Add a new step by clicking on ‘+ New step’

    Power Automate Empty Function new step

    Add a new step

  3. Search for ‘initialize’ and click on ‘Initialize variable’

    Power Automate Empty Function initialize variable

    Add Initialize variable action

  4. Setup Initialize variable: 1) Provide a name, 2) select type Array, 3) Set value to ‘[]’

    Power Automate Empty Function initialize variable setup

    Setup variable

  5. Add a compose step by searching for ‘compose’ and clicking on ‘Compose’

    Power Automate Empty Function add compose step

    Add Compose action

  6. Setup compose action: 1) click into Inputs (popup appears), 2) click on ‘Expressions’, 3) set expression to ‘empty(variables(‘myArray’))’ 4) click on ‘OK’

    Power Automate Empty expression setup

    Setup empty expression in Power Automate

  7. Save and do a test run

    Power Automate Empty Function result test run

    Result test run – Power Automate empty function example

Leave a Comment

Your email address will not be published. Required fields are marked *