Dynamic list of Days, Weeks, and Months for building Relations

Hello all,

In my app (100% Glide Table) have a table of logs that I want to create relations with so that have tables I can build charts off of.

In a previous post @ThinhDinh helped me create a list of Mondays utilizing the “Row ID + lookup_Row ID + Find Element Index + Math” strategy.

Question #1: I currently have 156 rows and being that there’s 52 weeks per year that means this will cover me for 3 years. This strategy is fine, I’ll just need to remember to add more rows later. I suppose I could add 1000 rows which would cover me for the next 20 years. Is there a way to make this list truly dynamic?

Question #2: I want to make a similar table for Days. The method for Weeks would work, but it would just require 365 rows per year. Is there a better way to go about this?

Question #3: The real help I need is with Months. This one is throwing me for a loop. I’m read other posts relating to working with months but I haven’t read anything that I have been able to apply to my scenario. That doesn’t mean a solution isn’t out there, it just means I haven’t been able to find a solution. The approach for Weeks works by using a Math column with “currentMonday - Index*7” to generate the list of Mondays. But Months are wonky and don’t play nicely because some months are 31, 30, 28, or 29 days.

@Jeff_Hager’s method in this post might be of use to me, but I’m not sure how to get the months to dynamically descend like I did for Weeks.

Do you need this to go on indefinitely, or could you limit it to X number of weeks?
If you can set a limit, then yes it’s possible to set it up in such a way that the oldest week drops off the list as each new week rolls over.

Same question as above, I think. The answer mostly depends on how you’re using the data and the maximum number of days you’d ever want to have visible at once.

Yeah, this one is tricky. I do have a solution for this that involves a bit of fancy math and other data editor logic, but I can’t get at it right now. If nobody else offers up a solution I can provide it later.

1 Like

Same thoughts as Darren above, if you want to drop off old weeks, you can have a setup so that the 1st row moves along with real time, and that will move the latter rows as well.

N-DAY(N)+15+30*I-DAY(N-DAY(N)+15+30*I)+1

A bit of a same setup really.

2 Likes

Indefinite feels nice, because it is one less thing to worry about or keep track of, but in all actuality it probably isn’t necessary. It is more likely that the app or Glide will change before the finite number of rows I prepare are used up.

Days: 2 years >> 730 rows
Weeks: 4 years >> 208 rows
Months: 6 years. >> 72 rows
Years: 10 years >> 10 rows

But nevertheless I’m curious about the solution if I did need to let it go on indefinitely. What would that be?

Beautiful! Wow I like that. Thank you, @ThinhDinh!

Well you’d just have to keep adding rows. You could use some sort of automation tool in conjunction with the API, but in this case it would probably be easier to just add them manually.

1 Like

Ah I see, the manual method does seem more appropriate for this case. Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.