filter and select data in Microsoft Graph

Within my series about Microsoft Graph in the Power Platform I’ve collected data using customer connectors and HTTP actions but how do we filter and select data in Microsoft Graph?

Filter Action

To filter our data that we get returned we could use the filter action. But that would mean collecting too much data before we select what we really want.

This of course isn’t a great approach.

Filtering data in Power Automate

Probably my most popular posts from a few years back are about the Filter options within the get items action and the even older post that shows the raw filter options without enabling the experimental features.

Before we look at Microsoft Graph’s filter and select options it is important to check out those two posts. One of the examples of filtering items that I gave before is the below filter:

(stringColumn eq 'string') and (numberColumn lt 123)

With the syntax of fieldname operation value we can filter our items before they arrive.

Microsoft Graph and filtering

When we want to filter items we could first call the Graph API to collect our data and then filter the data. It doesn’t really matter if we use a custom connector here or if we use the raw HTTP action.

2 Approaches to filtering and selecting data from Microsoft Graph in Power Automate

This would mean that we first collect the data before filtering the data. This may sometimes make sense. If we want to collect all the data once and then filter the data multiple times to get different subset of the overall data. Howevr in general it is better to filter the data before receiving the data.

In standard Graph/REST APIs we can use a $filter parameter in the URL.

We would potentially use something like this in our endpoint:

https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName, 'Pieter')

But Power Automate doesn’t like that.

2 Approaches to filtering and selecting data from Microsoft Graph in Power Automate

To get this done within the HTTP action we can specify a query.

2 Approaches to filtering and selecting data from Microsoft Graph in Power Automate

In a similar way we can also add a select query, which will control which fields we will get returned.

2 Approaches to filtering and selecting data from Microsoft Graph in Power Automate

So now we can filter and select data coming from Microsoft Graph.

Avatar for Pieter Veenstra

By Pieter Veenstra

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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading