Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
Not applicable

Selecting X amount of random records from a table

I have a table right now that is set up up in the following way:

SurveysTable:

SurveyID Comment Positive Negative

32 good job 1 0

84 bad job 0 1

247 way to go 1 0

... ....

I'd like to create a list box or a straight table that will show 10 randomly picked comments from this table.

Thanks in advance,

Paulo

1 Solution

Accepted Solutions
Not applicable

Selecting X amount of random records from a table

But it selects 10% of the records.

To select exactly 10, I create in the script a new field :

Rand() as U

Then in a chart or list, I can select the 10 biggest or lowest value of U ( using rank function)

JJJ

View solution in original post

3 Replies

Selecting X amount of random records from a table

Hello Paulo,

You can create a sample table so you get some values to show, for example

SAMPLE 0.10 LOAD SurveyID AS SampleSurveyID, Comment AS SampleComment RESIDENT SurveysTable;


By adjusting that 0.10 you will narrow your results down.

Hope that helps.

Not applicable

Selecting X amount of random records from a table

But it selects 10% of the records.

To select exactly 10, I create in the script a new field :

Rand() as U

Then in a chart or list, I can select the 10 biggest or lowest value of U ( using rank function)

JJJ

View solution in original post

Not applicable

Selecting X amount of random records from a table

Jean-Jacques,

That is exactly what I ended up doing. It's a different way to think about generating random records, but it works just fine for my purposes, and it is in fact still random.

In my mind, I was trying to go through a loop that would choose 10 random RowNumbers and load those records into another table. The SAMPLE method is actually useful as well, but like I mentioned, I wanted a very specific number of records. I'll definitely keep that method in mind tho.

Thanks for the suggestions guys, if anyone has any other ideas just let me know.