RAND () Function not working with Dynamic Data fields

I’m finding an issue where RAND() function does not work if you add in limits based on database min/max variables.

I’ve tried to set the maximum number on the RAND function to the count of the database, to the min/max, and the max.

Is there a way to make this work or does RAND not take dynamic variables?

I had wanted the limits to be dynamic, setting the numbers to draw a random number associated with the ID of the advertisements in a database.

It works if I use plain numbers.
If I set it with a dynamic variable, it breaks the entire screen that the RAND Input is located and gives the white screen of death instead.

Feels like a fatal flaw. Unless I’ve missed something.

Any help would be appreciated, thanks

I updated with a screengrab. I thought I had already added it.

A lot of functions don’t work. Counts don’t always work when they’re inside a list. Custom formulas don’t always work. Date functions don’t always work. Pretty much everything is hit or miss. It’s seemingly random, and breaks what should be simple functionality all over the place.

What I’ve done, is whenever a function isn’t working right, and I can’t get it to work no matter how simple and straightforward it is, I “simply” create an elaborate workaround to achieve the same goal. For instance, you may need to run the function in a different context and “store” the result in a hidden text input component, then reference that text input component to achieve your end goal.

So, in other words, when 2+2 doesn’t equal 4 for some stupid reason, just use 2+6-12/3, and you’ll get your 4 result!

If anyone would like to know how I decided to ultimately make this work,

I added a column ‘Random AD’ number variable to each user profile (a database field that takes up permanent space, which is inefficient and causes bloat - Adalo team, take note - it leads to lag!)

When the ad is finished (timer that counts down on the ad page) before it lets the user move on to the next page in the app, it "updates’ User with rand(1,advertisement max) in that Random AD field.
This works for the next ad display.

I decided to generate the number after the ad displays to prevent delay in serving the ads when the user lands on the page for the first time. Any delay at all in serving up the ad will make it look like your app is running slow. Even a fraction of a second of a blank screen makes it look like you’re buggy. Instead, add the fraction of a second to the back end since it’s a light update (simply changing a variable) and if it fails to update, they get the same ad twice in a row, not a huge deal. I am fine with that failing to update properly from time to time, and people seeing some ads in a row, than with having the ad fail to load.
It’s not about the amount of time the ad is seen.
It’s the perception on the user side - when you’re waiting to see a screen load once it has appeared, you notice how long it takes before something appears for your eyes to focus on.
Versus when an ad is displaying for several seconds and you don’t care, you’re waiting for the next thing - when the ad initially disappears is when your user then focuses on the screen again and at this stage, it takes them a second to realize something is even happening.

The reason I chose the ‘Max’ instead of ‘count’ is because as the Adalo database grows, it appears the system gets bogged down having to pull EVERY record and then count it. By selecting max (I do have a variable that is Ad ID that I’m pulling from), I can more efficiently find out what the max number is.

Again, you don’t notice these things in testing / in the first stages of building an app. These are variables that drag your database performance down over time as it gets more and more bloated.

I would much prefer the original method I had outlined. As soon as that’s an option, I’ll be shifting to that method and removing this less efficient method.

Initially, the hiccup is that the first ad they ever see in the app may be blank (I dont think anyone will mind). But after that, it will set the next random ad ID for the next time they see an advertisement.

Again, this is not efficient.

Adalo needs to get their RAND() function working properly as I had originally described it.

Random generated numbers should not need to be stored for every user in this way.
**Multiply this across hundreds, thousands of users, you’re putting twice as much stress on pulling/updating information which is twice the work load for your databases. **
I’m being forced to update a field on every page exit to make this work when I shouldn’t need to and then call that field when I come back to that page and display it.
**This is double the work on the database and servers. **
And you’re data heavy.

Take some of that funding money, Adalo, and get someone that understands this kinda stuff.
No amount of marketing is going to save you if you’re churning users left and right because of unreliable ‘basics’ and bad logic / bloated data / slower services.

I think Adalo has the funding to fix this entire mess. Now, simply a matter of deploying that capital efficiently / effectively in the right places. Adalo appears to be in the hire/fire stage and I hope that means you’re getting your house in order.

RAND() does not work properly in this use case, it breaks the page.
So this is the work around I applied.

I removed the ‘Input’ field on the page. Instead, this is generating the RAND() directly in the Random AD database field using Update for the User. This sets the random number in that field for the next ad display.

Thank you for your response. I tested this over and over, looking for a fix, but unfortunately it simply breaks the page. I even reverse engineered and had the numbers all display in the input field without the RAND function to make sure that the numbers were displaying correctly within () but as soon as I put the dynamic variables in the RAND() function, it broke the entire page.

It’s frustrating, I feel the exact same way.

Thank you for taking the time to comment.

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