Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Problem with variable


I have a problem with initializing variable.  In flow I'm trying to achieve automate deletion of files which are older than 7 days. But variable is the last thing that is doing problems. I've looked at lot of forums but it is not working. 

There is the variable:



greater(utcNow('yyyyMMdd'), formatDateTime(adddays(item()?['Created'],7),'yyyyMMdd'))



  There is scheme of Flow: 


Many thanks for any support!

Super User II
Super User II

Re: Problem with variable


Hi there.  It looks like the expression in your variable is referencing something that hasn't happened yet (with the item() part).


Try initializing the variable like you have it, but leave the value blank.

Then after your Get file properties bit, add a "Set variable" action with that same expression.  It may want to be inside of your Apply to each loop, not sure.


Also, check out using a Compose rather than the variable.  It might work better for you, as well.

Keep us posted.



If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

Frequent Visitor

Re: Problem with variable


I've tried to do that as you said and it doesn't work. I guess  there is problem in me, because I do not understand Flow very well 😄
Value in item() is blank. 


Here I just deleted "7"

greater(utcNow('yyyyMMdd'), formatDateTime(adddays(item()?['Created'],'yyyyMMdd'))


Helpful resources


Super User Program Update

Three Super User rank tiers have been launched!


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021


New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!


Power Automate Community User Group Member Badge

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

Top Solution Authors
Users online (7,068)