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?
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.
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:
But Power Automate doesn’t like that.
To get this done within the HTTP action we can specify a query.
In a similar way we can also add a select query, which will control which fields we will get returned.
So now we can filter and select data coming from Microsoft Graph.