cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

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

 

ContractsExpiryDate.png

 

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')

 

varToday.png

 

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

odata filter.png

3 REPLIES 3
Highlighted
Dual Super User III
Dual Super User III

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

@HenningStrand

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

https://powerusers.microsoft.com/t5/Building-Flows/ODATA-filter-using-And-operator/td-p/70273



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Community Support
Community Support

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,

Kris

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.
Highlighted
Advocate II
Advocate II

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.

 

FlowFilterCondition.png

 

 

Kind regards

Henning

Helpful resources

Announcements
Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Top Solution Authors
Top Kudoed Authors
Users online (4,759)