Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Generate a random number of 6 digits

bersocha
7 - Meteor

Hi community. I need to generate several random numbers but all of them need must be 6 digits.

 

I’m guessing I need to use the Rand() formula but I’m not been able to set the numbers to be only 6 digits.


Thanks in advance.

4 REPLIES 4
IraWatt
17 - Castor
17 - Castor

Hey @bersocha,

There is probably a smarter way of doing this but here is one option:

IraWatt_0-1654205112325.png

 

ToString(RandInt(9)) +
ToString(RandInt(9)) +
ToString(RandInt(9)) +
ToString(RandInt(9)) +
ToString(RandInt(9)) +
ToString(RandInt(9)) 

 

If you want the minimum option to be 100,000 could do this:

 

ToString(RandInt(8)+1) +
ToString(RandInt(9)) +
ToString(RandInt(9)) +
ToString(RandInt(9)) +
ToString(RandInt(9)) +
ToString(RandInt(9)) 

By 6 digits is 000001 a valid option?

Any questions or issues please ask :)
HTH!
Ira

 

cfugat
5 - Atom

if you are looking for exactly 6 digits (no less) you can use the formula RandInt(899999)+100000. 

RandInt(899999) would give you a random integer between 1 and 899,999 then adding 100,000 would ensure that it is 6 digits.

 

 

Darmanto
5 - Atom

1234567890

aatalai
14 - Magnetar

@bersocha if you have access to the R tools you can try using monte Carlo simulation

Labels