Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Leverage your QlikView investment to modernize BI – see how! Join Group
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Specialist
Specialist

Assign random number

Hi all,

I have a table of around 750.000 lines, in which around 20 products are comprised over these lines. My issue is that the table is ordered on the product type, and so product 1 will be stting in the first lines, and product 20 in the last lines (I don't easily know how many lines each product has).

My wish is to assign a random number (from 1 to 750.000) to each line in the table, so that when I order the table on the random number, all products are mixed. I've looked at Autonumber and Rand, but those don't seem to be helpful.

Is there any other solution possible?

Thanks

1 Solution

Accepted Solutions
Highlighted
MVP & Luminary
MVP & Luminary

Re: Assign random number

Try ceil(Rand()*750000))


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Highlighted
MVP
MVP

Re: Assign random number

RowNo() as ID is not working for you..

Or you are looking for something different?

Can you provide little 5-6 line sample with your required output?

Highlighted
MVP & Luminary
MVP & Luminary

Re: Assign random number

Try ceil(Rand()*750000))


talk is cheap, supply exceeds demand

View solution in original post

Highlighted
Specialist
Specialist

Re: Assign random number

Thank you, this does the job perfectly. With the function, I now get an average that has only a spread between the different products of around 35.000, whereas it used to be 12.100.000 with the ordered table. So this is certainly an improvement. (average calculated over either the line ID = rowno and the solution above)