cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SLCLARKE
Helper II
Helper II

Flow to move expired items which are older then a year

At the moment when the expiry date pasts the todays date the status chnages from Due to Expired - this all works.

 

I am trying to set up a flow, so that when expired items are older then a year the status becomes Archived.

 

I just cant get it to work?

 

I have used the following:

 

The column of the date is called ExpiryDate

 

addDays(items('Apply_to_each')?['ExpiryDate'],365)

 

formatDateTime(utcNow(),'yyyy-MM-dd')

 

SLCLARKE_0-1652871718140.png

 

 

 

3 REPLIES 3
tom_riha
Super User
Super User

Hello @SLCLARKE ,

instead of using 'Get items' to get all items and then loop through them and evaluate them one by one, you could filter them right away in the 'Get items'. That way it'll return only the items that fit the condition and you can process them directly in the loop without the condition.

The Filter Query in 'Get items' might look like below:

ExpiryDate lt '@{getPastTime(1,'Year')}'


[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Thank you for your help. I just have the following error:

 

SLCLARKE_1-1652949832469.png

 

Hello @SLCLARKE ,

as the error tells you, you can't use calculated column in the 'Filter Query'. You must move the calculation from the column directly into the flow as explained here and base it on the date column that you use as the source for the calculated one.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,701)