web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create a flow that dyn...
Power Automate
Unanswered

Create a flow that dynamically checks a day count and updates items

(0) ShareShare
ReportReport
Posted on by 35

Hello,

 

I have this bit of code, I'll provide some context here, 

 

I check the days elapsed; it counts down for everyday past. When the day count reached 0, I update the SP list.

 

How could I build a flow to automate this? I don't want to have to open my PowerApp every time the count reaches 0.

 

OnVisible:

 

 Set(                                                                                     <--     Here I'm setting the days elapsed to the earliest score date
    varDaysElapsed,
          DateDiff(
   First(Sort(
       Filter(
              'Game Scores',
              'Score Date' >= Today() - 90
           ), 'Score Date',SortOrder.Ascending)
          ).'Score Date',
Today(),
   TimeUnit.Days
   )
);

 

Set(varDaycount, 90-varDaysElapsed);            <--     Here I'm setting a variable which counts from 90 days

 

If(varDaycount = 0,                             <--     When the day count reaches 0, I update these records

UpdateIf('Game Scores', 'Hide Records'.Value <> "Yes", {'Hide Records': {Value: "Yes"}})

 

);

 

Any advice would be appreciated, thanks!

Categories:
I have the same question (0)
  • Verified answer
    v-jefferni Profile Picture
    on at

    Hi @Jake_Daniels_9 ,

     

    I assume you have an entry in 'Game Scores' data source, with its 'Score Date' = Today() - 90. So, the varDaysElapsed equals to 90 and varDaycount equals to 0. At this point, the UpdateIf function will fire. In other words, the entry that 'Score Date' = Today() - 90 will bulk update 'Game Scores' with entries that 'Hide Records'.Value <> "Yes", which doesn't make sense. 

     

    Based on my understanding, what you want is update the 'Hide Records' Choice column to "Yes" for entries where 'Score Date' value = Today() - 90. If this is the case, you can create a scheduled flow which runs every day, get items that 'Score Date' value = Today() - 90 from Game Scores using filter query or filter array, loop through the results, update item and change Hide Records to Yes.

     

    Best regards,

  • Jake_Daniels_9 Profile Picture
    35 on at

    Hi @v-jefferni ,

     

    Sorry, I used misleading naming conventions. It's not as you say, I can give you more details here.

    So, I have a scoreboard which sums up scores for every quarter (last 90 days) then on the 90th day, the first or highest score per board should be written to another table. 

     

    The problem with filtering my gallery by, records>=Today()-90, is that some scores would be carried through into the next quarter. 

     

    The hide record naming convention is something I initially thought about to hide the records from my galleries by filtering it out.

     

    The solution I came up with works like this, (I'd like to have this in PowerAutomate, So I don't have to run the app for onvisible every time the counter reaches 0)

     

    Note that I changed the naming of Hide Records to IsArchived,

     

    Every last 90 day block of records =

    Jake_Daniels_9_0-1702362914861.png

    I then calculate the days elapsed,

     

    DateDiff in days

    Between First Record Date & Today() = Day Difference

     

    THEN,

     

    90 – Day Difference = Day Count

    E.g., 89,88,87,86 … 0

     

    Eventually,

     

    I write the highest scores to another table,

    With something like this,

     

    If(varDaycount = 0,

    If(CountRows(Filter('Games Win History',Text('Date of Entry',"mm/dd/yyyy") = Text(Today(),"mm/dd/yyyy") && 'Game Played'="All Games")) = 0,

    Collect(ColAllGames,'Game Scores');

    ClearCollect(ColAllGamesPatched, First(Gallery1.AllItems));

    Set(myrecord, LookUp('Games Win History', myrecord.ID = ID));

    Patch('Games Win History',
    ForAll(Gallery1_1.AllItems,
    {
    SumofValue: Gallery1_1.Selected.'Sum of Value',
    TeamAliasText: Gallery1_1.Selected.TeamAliasText,
    'Game Played': "All Games"
    }
    )
    )));

     

    Once that is done, 

     

    While Day Count still = 0,

    Update all existing scores to IsArchived = Yes

    Move all IsArchived = Yes records to Table: Game Scores Archived using a flow

     

    So again, it's all dependent on the Day Count being 0. How can I do this in PowerAutomate? i.e., have an automatic count that performs these actions, so that I don't have to open the PowerApp every time the count = 0 to make sure all the code on, onvisible is executed.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard