alteryx Community

# 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

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.

2 REPLIES 2
17 - Castor

Hey @bersocha,

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

``````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

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.

Labels