So, imagine we have two columns in our spreadsheet: Column A = Priority, under which you have three available values from a drop down = 1, 2 and 3. Priority 1 is “highest”, Priority 3 is “lowest”. Column B = Deadline, used only to set up dates, no times (Data validation > Date).
So, we have filled in a few rows randomly. For example: A2=1, B2=25th Aug 2021; A3=2, B3=30th Aug 2021; A4=3, B4=31st Aug 2021; A5=2, B5=9th Sept2021; etc..
Now, I want to write a script (or even if possible - only use spreadsheet formulas) that automatically changes the Priority value to its "higher" number, depending on how close we are to the deadline.
NOTE: obviously, the rows which have Priority 1 already, don’t need to be affected by this rule. This only applies for rows with Priority 2 and 3.
Logic kinda must look like this:
//remaining time = number of days between NOW and deadline 00:00h.
What is today’s date? What is this row's Deadline? Calculate remaining time (Deadline 00:00h minus ).
If [this row's Priority = 3] AND [3 days < remaining time <= 7 days], THEN change Priority value to “2”.
If [this row's Priority = 2] AND [remaining time <= 3 days], THEN change Priority to “1”.
Move onto next row, keep scanning and changing Priority values wherever their corresponding deadline matches one of the above rules.
Obviously, I plan to use this for a task tracker. So my goal is to make sure that, e.g. if I add a task with deadline after 1 month and give it Priority = 3, the closer I get to the deadline, the higher it jumps into my Priority order.
I hope this makes sense! I can’t think of a clever way to pull this off with Formulas. And I don’t know App Script well enough, though if I’m presented with a solution to the above example, I would be able to edit it for the purposes of my Task management spreadsheet.
Thanks in advance!