6 Ways to Create a Condition If Blank in Power Automate

Do you need to create a condition based on blank values from your data source in Power Automate?

Blank values in your data will be a common occurrence. The absence of data can be an intentional situation meaning something, or it can be an omission error.

Whatever the situation, this is something you will need to account for in your flows by building conditional logic that deals with blank values.

The condition you set up will depend on the data source and the data type in that data source.

    This post is going to show you the different methods to create your condition if blank logic in your flow.

    Condition If Blank with Blank Value

    The first method will work for a lot of scalar value text and number fields from simple data sources such as Excel, or Microsoft Forms.

    These data sources don’t have complex data types that contain arrays or records.

    When you leave a field blank in these data sources, they will return an empty string value in Power Automate.

    If you leave the value field empty this will compare the value in the field to an empty string!

    If your item is blank the condition will result in the If yes actions getting executed. If your item is not blank, then the If no actions will run.

    Condition If Blank with the String Function

    Since the simple data types will return an empty string value in Power Automate when they are blank, this means you can compare them to an empty string to create your condition.

    How can you create an empty string?

    string('')

    This can be done with the above expression using the string function. The two single quotation marks with nothing between them will create an empty string.

    📝 Note: You need to use the string function to create an empty string. Adding '' directly into the condition value field won’t work the same way.

    Condition If Blank with a NULL Value

    When dealing with more complex data sources such as SharePoint lists, the previous two strategies won’t work.

    When you leave a text field blank in your SharePoint list, it doesn’t return an empty string to Power Automate.

    In fact, it doesn’t return anything at all! You won’t find that field for your record in the flow output.

    This means you will need to use a null value in your condition if blank statement.

    Typing the word null into the value field won’t work. This needs to be entered as an expression.

    1. Select the value field in your Condition action.
    2. Go to the Expression tab.
    3. Type null in the expression editor.
    4. Press the OK button.

    This will enter a null expression instead of just the string null into your comparison field for the condition.

    Condition If Blank with Empty Function

    SharePoint has some more complex data types that will return an array of values, such as a multi-select person field.

    When the multi-select person field is left blank in SharePoint, it will return an empty array [] to Power Automate.

    This means you need to check if the array is empty. This can be done with the empty function, which returns true if an array is empty.

    empty(items('Apply_to_each_SharePoint')?['Users'])

    The above expression will check if the array from the Users field is empty.

    Since the empty function returns a true or false value, you need to compare this to either true or false on the left side of the condition. This true value also needs to be entered as an expression.

    Condition If Blank with Length Function

    Another way to check if an array is empty is to use the length function.

    The length function will return the number of items in an array. If the number is zero then the array is empty.

    length(items('Apply_to_each_SharePoint')?['Users'])

    The above expression will return the count of the number of items in the array returned from the Users field.

    On the right side of the condition, you will add a 0.

    When the length function returns 0, the array is empty and your field is blank in the source SharePoint list.

    Condition If Blank for Any Source

    Perhaps you are testing different data sources in a dynamic way within the same condition.

    You might then need to test all the above conditions. This can be done using an OR in your condition logic.

    1. Click the Add button at the bottom of your Condition action.
    2. Select the Add row option.

    Repeat this until you have 5 rows in your condition.

    1. Select Or in the dropdown at the top of your Condition.
    2. Add each of the previous methods into the rows.

    This example will test the output of the Compose action with the previous 5 methods to test if the value in the Compose action is blank.

    {"id":"cb1526aa-9c9a-4340-aec9-c9add64f3df4","brandColor":"#8C3900","connectionReferences":{"shared_sharepointonline":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/6f1cb93d845b4507abf583e68cef604a"}},"shared_excelonlinebusiness":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_excelonlinebusiness/connections/shared-excelonlinebu-050317b5-b32a-4edf-863f-8434e1ac8ac3"}}},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"Scope","operationDefinition":{"type":"Scope","actions":{"Compose":{"type":"Compose","inputs":"Your field reference goes here!","runAfter":{},"metadata":{"operationMetadataId":"79b0730c-041d-4d9e-b9df-780c98b1e2d9"}},"Condition":{"type":"If","expression":{"or":[{"equals":["@outputs('Compose')",""]},{"equals":["@outputs('Compose')","@string('')"]},{"equals":["@outputs('Compose')","@null"]},{"equals":["@empty(outputs('Compose'))","@true"]},{"equals":["@length(outputs('Compose'))",0]}]},"actions":{},"runAfter":{"Compose":["Succeeded"]},"metadata":{"operationMetadataId":"1bd06bf7-e59a-46d6-8a53-19ce86064144"}}},"runAfter":{"Value":["Succeeded"]}}}

    Since this might take a few minutes to set up manually each time. It might be worth using the above Copy to my clipboard code.

    You can copy and paste this code into your flow.

    1. Add a New step to your flow.
    2. Go to My clipboard.
    3. Press Ctrl + V on your keyboard.

    This will copy a Scrope action with the Compose and Condition actions all filled in for you.

    Conclusions

    Blank values will come up all the time in your source data, and you might need to accommodate for them in your flows.

    Unfortunately, this is not straightforward as how you test for blank values will depend on the data source and data type.

    These methods should allow you to test any type of blank you come across.

    Have you needed to test a condition if blank? How did you do this? Let me know in the comments!

    About the Author

    John MacDougall

    John MacDougall

    John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

    Subscribe

    Subscribe for awesome tech videos 😃

    Related Articles

    Comments

    0 Comments

    Submit a Comment

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

    Get the Latest Tech Tips

    Write For Us

    Are you a tech enthusiast with a talent for writing great content? Come write for us!

    Follow Us

    Follow us on social media to stay up to date with the latest in tech!