Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
JohnnyBravo
Contributor
Contributor

Randomly assign records to users based on number of records

Hi Community

I am stuck so I have a requirement which is kind of unique that I have to assign records to users randomly based on number of records for example if I have lets say 100 records I want to assign 25 records to User A, 25 records to User B, 25 records to User C and 25 records to User D. I want to make this as reusable jobs so it can be leveraged with other jobs.

Thanks

JB

Labels (4)
2 Replies
Anonymous
Not applicable

Hi

I think we need more details to help you out, show us some input example data and what are your expected output?

 

Regards

Shong

 

billimmer
Creator III
Creator III

Pass the table name and the number of users as context variables to a subjob. In the subjob use execute a count query on the table. Divide the count by the number of users.

 

For example if this was a Postgresql DB you would have:

 

tPostgresqlInput ---row----> tSetGlobalVar. ----componentOk---->tjava

 

To return the number of records from the subjob you will either need to use a tBufferOutput. So add to this tFixedFlowInput----row--->tBufferOutput.

 

Or instead to return the value you can create a variable in a code routine. I do this as it's much easier to manage. I create a code routine and create public variables called:

 

retString1

retInteger1

etc...

 

Then you can assign them in the subjob and use them in your main job as they are static.

 

myCodeJobName.retInteger1 = context.param_table_record_count / context.param_person_count;