Microsoft Office 365

Filter null values in Dataverse using Power Automate

Filtering records on empty values can be a real pain as there are many mistakes to make.

Null

First of all I would like to have a look at the null function. Many times, I’ve seen people ask the question why their null values haven’t been working. Below 3 examples. Only one will really work.

In Power Automate you can have an expression null.

Compose action with null expressions

You can type the text null (this is just 4 characters, n,u,l,l)

Compose action with null text

And then you can have empty strings (i.e. don’t fill in anything). The Compose action will not accept this as the input is required.

Compose action with no content

Mistake – Filter rows

Now how would we use the filter rows option to get just the records where a specified field is empty? You might want to try this:

Filter rows with null filter

Well the null function isn’t going to work like that! The above query will be evaluated as accountnumber eq

The eq operator has to have something on the right.

Also if you replaced the above with accountnumber eq ” you would only get the empty string values. which isn’t exactly the same as nothing. Huh???

When a field is not set Dataverse will not return that field at all and nothing is not the same as an empty string.

So how do we make this work?

Filter by null values – option 1

Now we can make use of FetchXml to filter by null values.

So for example if I wanted to find the accounts without an account number set I could use the following query:

Fetch Xml with null expression

Filter by null values – option 2

Then there is a second option to filter by null values (Thanks Marcel, see comments below)

accountnumber eq null

So by not typing the expression but the text null without quotes will also work.

Filter by not null values

And in a similar way I could also find all the records that do have an account number set:

Fetch Xml with not-null expression

All that is needed to filter your records are the null and not-null operators.

<fetch mapping='logical'>  
   <entity name='account'>   
      <attribute name='accountid'/>   
      <attribute name='name'/>   
      <attribute name='accountnumber'/> 
      <filter>
            <condition  attribute='accountnumber' operator='not-null'/>
        </filter>
   </entity>   
</fetch> 
Share
Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

View Comments

  • Hi Pieter,
    The filters are converted to OData filters. It is possible to do the filtering without using the fetchXML option.
    The correct notation would be: accountnumber eq null
    So not the expression but just as text

Recent Posts

Introducing 8 AI Functions for Dataverse in Power Apps

Recently Microsoft added AI Functions to Dataverse that can be used in Power Apps. In…

22 hours ago

Copy and paste Scope steps in the new Power Automate Designer

One of the outstanding issues with the new Power Automate Designer is Copy and Paste…

1 week ago

Receive the available storage within your SharePoint Online tenant

Within the SharePoint admin centre there is that little detailed overview, telling you the available…

4 weeks ago

Options for Documenting Your Power Apps: Comments, Code, and Controls

Within Power Apps there are various ways to document your app. In this post I'm…

1 month ago

2 ways to duplicate SharePoint Lists to support your Power Apps

Recently I've been asked quite a few times to duplicate SharePoint lists as part of…

1 month ago

Update a Hyperlink Column in SharePoint with Power Automate

Today, I was asked about how to create a lookup to a document or item…

1 month ago