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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Random numbers creation?

Hi All,

How can I randomly assign either 2 or 3 to a field? I know I have to use rand() function but not sure how to make it only assign 2 and 3

Thanks!

1 Solution

Accepted Solutions
3 Replies
sunny_talwar

May be like this:

If(Rand() < 0.5, 2, 3)

sunny_talwar

or

If(Rand() <= 0.5, 2, 3)

trdandamudi
Master II
Master II

Just an idea:

Insert a Row number in your table and based on the row number (Whether it is even or odd) assign either 2 or 3 to your field...