Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

How to use IF/THEN and subtract date function in the Get files action's ODATA Filter Query field?

Simply put I need to only get the files that have the property WarningDate earlier than Today into my Flow.


In SharePoint WarningDate is of type calculated column, which unfortunately is not supported used in the Filter Query field of the action, and so I need to figure out how to do the same calculation using ODATA in the action filter. Hope someone can point me in the right direction!? 


The calculated column finds the value like this: =IF([Alert period (days)]<>"No alert",[Contract End]-[Alert period (days)],"01/01/9999")

In people speak: IF the Alert period field is not 'No Alert' THEN subtract number of days from Contract End date ELSE set to Jan 1st 9999




The Today part of the ODATA I have figured out already, and it works fine. I will do like this:


[the calculation I am asking for] lt varToday 


where varToday is a variable set to: formatDateTime(utcNow(),'yyyy-MM-dd')




Here the filter is in the current state without the part that I am waiting for tips on:

odata filter.png

Dual Super User
Dual Super User

Re: How to use IF/THEN and subtract date function in the Get files action's ODATA Filter Query field


According to this recent thread, AND ODATA filter query operator is not currently supported

If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!

Community Support Team
Community Support Team

Re: How to use IF/THEN and subtract date function in the Get files action's ODATA Filter Query field

Hi @HenningStrand,


Do you get the files from SharePoint document library?

Could you please share a full screenshot of your flow’s configuration?

The date time column of SharePoint would be converted into UTC format automatically in Microsoft Flow:6.JPG

Note: WarningDate is a calculated column in my SharePoint library with the value like this:

=IF([Alert period (days)]<>"No alert",[Contract End]-[Alert period (days)],"01/01/9999")


There is no way to format the WarningDate column within Filter Query field of “Get files (properties only)” action of SharePoint in Microsoft Flow currently, so I afraid that we could not filter the files that have the property WarningDate earlier than today with Odata Filter Query within Filter Query field.


You could consider take an alternative way to achieve your needs, I have made a test on my side, please take a try with the following workaround:7.JPG

Within “Filter array” action, click “Edit in advanced mode”, type the following formula:

@less(formatDateTime(item()?['WarningDate'], 'MM/dd/yyyy'), utcNow('MM/dd/yyyy'))

The flow works successfully as below:8.JPG


Bets regards,


Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Level: Powered On

Re: How to use IF/THEN and subtract date function in the Get files action's ODATA Filter Query field

Hi and thanks for your replies.


First of all I find it strange to hear the the AND operator is not supported. I am getting no errors and my GET FILES filter seems to work fine, returning only items of the defined content type AND where the end date has not yet passed.


My main intention with putting as much filtering as possible into the query filter is to reduce the returned item count. As there is a current limitation of Flow not handling more than 5000 items I want to not have to do array fltering or conditions inside the flow. It's a lot better and simpler to not have to handle the unwanted items inside the flow at all. It's unfortunate that this is not possible. I was looking for something similar to a SQL CASE function. I'd still love to hear If it turns out that this actually is possible! 


Currently below is my 'work around' where I am using a condition to choose to only send alerts for the contracts that have an alert date earlier than today. Interestingly enough the calculated field works fine when used in a condition.





Kind regards


Helpful resources


Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!


Microsoft Learn

Learn how to build the business apps that you need.


Power Platform World Tour

Find out where you can attend!


Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 338 members 5,641 guests
Please welcome our newest community members: