Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
thomasmercer
Contributor III
Contributor III

Select handful of random records based on dynamic filtered data in a sheet

I have a sheet to be used for monitoring database automation, which contains a large number of records.

The sheet allows for drilling down by several different criteria to filter down the records, where users may identify certain irregularities.

Based on the filtered data I'd like to display a set of random distinct [JOB NO] values  in a text box or table against the filtered records for the user to help investigate irregularities identified.

I can use maxstring/minstring to pull a couple of values but ideally i'd like a true random selection of 5ish values in the filtered data.

Any ideas?

Cheers

Thomas

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If [JOB NO] is numeric, you could use min(field,rank) with some sort of sampling or randomizing of the rank parameter. 

If it's string, you could use 

FirstSortedValue([JOB NO], sort-weight, rank)

where sort-weight is some numeric field you can associate with JOBNO, perhaps generating a number in the script. 

-Rob

View solution in original post

4 Replies
gawalimegha
Contributor III
Contributor III

Hello Thomas,

You can use Autonumber() function in load script to achieve this.

 

syntax:  Autonumber([Job ID])

jonathandienst
Partner - Champion III
Partner - Champion III

You could load a random sample from your data source. Check out the SAMPLE keyword in the online help:

https://help.qlik.com/en-US/sense/September2018/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPre...

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If [JOB NO] is numeric, you could use min(field,rank) with some sort of sampling or randomizing of the rank parameter. 

If it's string, you could use 

FirstSortedValue([JOB NO], sort-weight, rank)

where sort-weight is some numeric field you can associate with JOBNO, perhaps generating a number in the script. 

-Rob

thomasmercer
Contributor III
Contributor III
Author

Thanks all, doing this dynamically within the sheet isn't easy as I'd hoped!

Rob's response gives me a fit for purpose result.

Cheers