Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Formula for creating random numbers

Bharath
8 - Asteroid

I have to assign random numbers between 0.6 - 1 for 500000 records in alteryx. I tried by using function called Randint() but its not working. can anyone please help me on this.

 

Thanks,

Bharath

10 REPLIES 10
JohnJPS
15 - Aurora

Try Rand() instead of RandInt(); it will give you a real number between 0 and 1; then multiply (e.g. Rand() * 0.6 for your case should be very close to what you need)

MarqueeCrew
20 - Arcturus
20 - Arcturus

(RANDINT(4000)/10000)+.6

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Bharath
8 - Asteroid

Hi Marquee, 

 

thank you for your reply. actually among the 500000 records some need to have 0.6, some should have 0.7, 0.8, 0.9 and 1 all these values should be randomly assigned for all the 50000 records. 

Bharath
8 - Asteroid

Acutally I am trying to crate a variable column with random values from 0.6 - 1.0. so some values should have 0.6 , some should have 0.7 and some should have 0.8,0.9 but i dont know how specify the interval from and to 

MarqueeCrew
20 - Arcturus
20 - Arcturus

they should.  I'm assigning values between 0 and 4,000 and then will be adding .6 to the product of the random number * .0001

this gets you random numbers between .6 and 1.

 

If you test this you should get min of .6 and max of 1 with avg of .8

 

Please do try it.  I've got a sample module included with 500,000 records (generated).

 

Thanks,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
JohnJPS
15 - Aurora

I think I understand; could you try

SWITCH(RandInt(4),1,
0,0.6,
1,0.7,
2,0.8,
3,0.9)

This will give only the distinct values 0.6, 0.7, 0.8, 0.9, and 1. ...

 

(edit: But @MarqueeCrew answer that follows is better.)

 

MarqueeCrew
20 - Arcturus
20 - Arcturus

if you only want {.6,.7,.8,.9,1} you can modify expression:

 

(RANDINT(4)/10)+.6

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Bharath
8 - Asteroid

Hi Marquee,

 

yes it works. thank you for helping me. but 0.9 value is not assigned while using htis formula. is there any specific reason for this ?

 

Thanks,

bharath

MarqueeCrew
20 - Arcturus
20 - Arcturus

I can only say RANDOM things happen.  Here is a count from my test of 500,000 values.

 

randCount
.699,714
.7100,117
.8100,058
.999,881
1100,230
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels