In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Random Number Between -1 and 1

naeema
6 - Meteoroid

Hi,

 

I am wondering how to generate a random number between negative and positive one.

 

I've found out how to generate a number between 0 and 1. But in terms of a negative number I've had no luck.

 

Any advice?                     

3 REPLIES 3
jdunkerley79
ACE Emeritus
ACE Emeritus

Use a formula tool with expression:

 

RAND()*2-1

Rand makes a random number between 0 and 1. Then you can double and shift.

naeema
6 - Meteoroid

I have decided to use two random Values, the second random value will decide whether the first random value is positive or negative (first random value is between 0 and 1).

 

Any better solutions?

martensite
8 - Asteroid

Hi,

 

If you only want to show these values: -1, 0 and 1. You can use the following formula:

 

SWITCH(RandInt(2),1,
0,-1,
1,0,
2,1)

Labels
Top Solution Authors