I would like to create a field with random numbers within a table ranging from 1- 10
I know the Autonum funtion doesnt work like this, im using it to display what i require...
Autonum(10) as [Client Code]
use function rand() and multiply the result by 10:
rand()*10 as myRandom
how would i limit it between 1 and 10 though?
rand returns numbers from 0 to 1 so left(rand()*10,1) gives you the result
RAND()*9+1 as NUM2
Ceil(rand()*11) as [Client Code]
For a better probability distribution (normal distribution) I recommend using:
=ceil(norminv(rand(), mean, stdev))
In your example e.g.
Thank you this is great
Which version of QlikView did you test the code on, that you marked as correct?
I only get 0 to 9.
Possibly a bug?
According to the QV Reference Manual v11 rand() returns a random number between 0 and 1, very possibly excluding 0 and 1.
And it delivers 1 to 10 using this expression?
Retrieving data ...