Rolling a random number between 1 and a variable

I've been looking through a bunch of threads here trying to find something similar to this, and they're either all buried or don't exist. I'm pretty bad with coding, and the things I've tried based on the little I've found isn't working.

I want to set a random number between 1 and (variable). So if the variable is 10, I want to set it anywhere from 1-10. I tried putting this in the "script" operand of control variables

rand($game_variables[47]) + 1

But the game just says rand isn't defined and crashes. I'm very unintuitive when it comes to this sort of thing, so would appreciate a quick bit of direction. Thank you.
This is the code behind Control Variables -> Random:

min + Math.randomInt(max - min + 1)
And this gets the value of game variable ID 47:

$gameVariables.value(47)
Putting that together:

1 + Math.randomInt($gameVariables.value(47));
This is the code behind Control Variables -> Random:

min + Math.randomInt(max - min + 1)

And this gets the value of game variable ID 47:

$gameVariables.value(47)

Putting that together:

1 + Math.randomInt($gameVariables.value(47));

Oh wow, thank you for the super fast reply. I knew starting the line with rand felt off. Thanks for the direction, that was super nice of you.

Appears to work exactly how it should. You're the best.

Original thread: https://forums.rpgmakerweb.com/threads/rolling-a-random-number-between-1-and-a-variable.149513/