cancel
Showing results for
Did you mean:

# Alteryx designer Discussions

## Floating point numbers are surprisingly strange

Atom

Hello guys,

Stuck at this simple one,

How can I generate a series of random numbers between a range of 2 numbers- something similar to randrange() in excel?

eg. I need a series of random numbers between 5.5  and 6.3.

Thanks and Regards,

Soham

Alteryx Certified Partner

Hi @SohamW

As far as I know, this is a not a built-in function of Alteryx.

However, I happen to handle this with a Macro.

Using Rand() function, you can have a number between 0 and 1.

You can use an Iterative Macro to "force" your Rand() function to fall between 0 and 0.8 (test it as many iterations as possible so it just outputs the result if it is in this interval) and then add 5.5 (as it's your starting point).

You basically get the same effect you're trying to produce.

Here's an example of how I would do it. Package with Macro appended.

Cheers,

Highlighted
Nebula

You can do this with the expression:

`Rand() * 0.8 + 5.5`

More generally:

`Rand()*(Max-Min) + Min`

Alteryx Certified Partner

Great idea @jdunkerley79

Also if you want to keep a certain precision with your decimals I thought of something similar to @jdunkerley79's solution

RandInt(8*number of zeros of precision you want to add) / 10*number of zeros of precision you want to add + 5.5

This will control the number of decimal places.you wanna keep.

Cheers,

Labels