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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Generating Yes/No values in fields

I'm creating data for a demo and trying to generate a Yes or No entry during a load into a bunch of fields in a LOAD. Is there any way do this using rand() or another function? Ideally, I'd like to not have an even distribution of Y/N if that's possible. Thanks!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Yes, you can do it using RAND() function:

LOAD

     if( RAND() < 0.3, 'Yes','No') as Answer,

     Recno() as AnswerID

Autogenerate 1000;

edit: This creates a 30% chance for a Yes answer (using 0.3). Just compare to different values between 0 and 1 to create other distributions.

View solution in original post

2 Replies
swuehl
MVP
MVP

Yes, you can do it using RAND() function:

LOAD

     if( RAND() < 0.3, 'Yes','No') as Answer,

     Recno() as AnswerID

Autogenerate 1000;

edit: This creates a 30% chance for a Yes answer (using 0.3). Just compare to different values between 0 and 1 to create other distributions.

Not applicable
Author

Thanks 'swuehl' - that was exactly what I was looking for!