Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
siddheshmane
Creator
Creator

Autogenerate Random Numbers

Hi,

I want to generate a list of Random Numbers that are Whole numbers and less than 50. I tried creating numbers but I always get a decimal number.

Can anyone tell me how can I obtain this result?

Thanks.

1 Solution

Accepted Solutions
pokassov
Specialist
Specialist

Hi!

t1:

Load RecNo( ) as A, round(50*rand( ),1) as B autogenerate(50);

View solution in original post

6 Replies
Anonymous
Not applicable

Multiply the decimal by 50 and then round it.

pokassov
Specialist
Specialist

Hi!

t1:

Load RecNo( ) as A, round(50*rand( ),1) as B autogenerate(50);

sunny_talwar

May be this:

LOAD Round(Rand() * 49) as RandNum

AutoGenerate 50;

Best,

Sunny

siddheshmane
Creator
Creator
Author

Hi,

Thanks, It worked. I also understood the concept very well.

Thanks.

rubenmarin1

Cepren solution is good one, but if you need equal probabilities between numbers, and from 1 to 50 you should use something a bit different (i generate 500000 to see the difference):

t1:

Load RecNo( ) as A, round(50*rand( ),1, 0.5)+0.5 as B autogenerate(500000);

If you don't add the offset the first and the last number has half the probabilities than other numbers:

I'm a bit idle today

siddheshmane
Creator
Creator
Author

Hehe.. thanks for explaining the offset part.. I didn't know that.