# How to use Dates or Times as triggers to rotate images in a Title Component

How to use Dates or Times as triggers to rotate images in a Title Component

Here is how I did it. There probably is a simpler way.

• Create an Array of the Images that you want to use
• Create a rollup column that counts the number of images in the array
• Create a math column that subtracts 1 from the count
• Create another math column that returns an integer value that will change at the frequency with which you want the images to rotate
• Create a Dice Roll column, using the second math column as the seed, and the Image Count -1 as the number of sides
• Create a math column that adds 1 to the Dice Roll column
• Create an Array Slice column that targets the Image Array, uses the Dice Roll as the Start, and Dice Roll + 1 as the end
• Use the Array Slice column as the source of a Single Value column
• Use the Single Value column as the image source of your Title Component.
1 Like

Nice. Thanks Darrenđź‘Ť Iâ€™ll try this. Some new calculation columns i havenâ€™t used before, will let you know how it goes.

In terms of the original question:
I did manage to get the single columns working but i needed it for many different title component images, so iâ€™m using multiple single column with first, 1, 2, 3, 4 etc

The dice roll column is very interesting.
Iâ€™m trying to figure out the inner workings of the dice roll column. It seems to provide a result that is not greater the rollup column, but itâ€™s being seeded with a wide range of numbers. Is the seed the number of rolls and the sides are the random result of rolling it the chosen number of rolls? Is it totally random or does it work like a type of modulus calculation where the result cannot be greater than the chosen modulus?

The seed provides the randomisation, and the number of sides provides the maximum value to be returned.

For example, if you were to provide a RowID as a seed, youâ€™d get a somewhat random distribution of results across all rows.

However, given the same seed value and the same number of sides, it will return the same number every time.

This is where using the time as a seed comes in. If you just feed it the current date/time value, youâ€™ll find that the result will change roughly every 10 seconds. This is because the current date/time in Glide updates every 10 seconds, and so the seed value changes.

If for example you wanted it to update every minute, you could create a math column using the formula `Minute(Now)`, and use that as the seed value. The result of this would change once per minute, and so youâ€™d get a new diceroll result every minute. The cycle would repeat every 60 minutes, but you could extend that if necessary by also using Day/Month/Year in the math column.

Okay great, iâ€™m seeding using the day so it doesnâ€™t change too regularly. But i must check how that affects my updates usage.
Iâ€™ll definitely keep playing around with the dice roll. I can think of a few other uses for thatđź‘Ť

I donâ€™t think it will have any impact on updates at all, because all you are doing is manipulating computed columns. And you can do that until the cows come home without incurring a single update.

Well thatâ€™s good to know.
I was actually pleasantly surprised to find out recently that the enterprise price plan has unlimited updates, which is really great because i have a multi choice dynamic search with three levels, which incurs one update each time you click on a choice, so for five choices for each level thatâ€™s 15 updates. Hectic! Blazing through the monthly updates quota!
At least i can use these image rotation features without any costs to updates (save them for my dynamic search)
Thanks for all your help @Darren_Murphy

PS. Hey just a quick one, i see that glide is using chat gpt for their search box on the main glide website, itâ€™s providing really accurate results for my questions that relate to documentation/how to build things etc. I didnâ€™t see an announcement for that. Do you have any news about that? It never came up with solutions anywhere close to your solution aboveđź¤Ż They should train it on solutions to questions solved by the community, then we can get a wider range of results in a few seconds flat.

We had an AI powered bot here in the Community a few weeks ago, responding to questions. It started off quite well, but went off the rails after a few days and started making random stuff up - referring users to non-existent features, etc. That was causing a bit of confusion, so it was switched off (werenâ€™t you @glide, you naughty bot). I suspect it might make a return once itâ€™s been fine tuned a little.

2 Likes

Hahađź¤Ł Got up to some mischief, sounds like a good idea though, got to keep that bot in line, while we still canâ€¦