Discussion board where members can get started with QlikView.
Hi, experts, i would like to know if there is a way to use the rand function but i pass the posible value, not only 1 or 0
i want to create random data but i provide the possible numbers, only create rando using that list of numbers
thank you a lot
Rand() only returns a numbers between 0 and 1. You can use the result of rand to select from a list of numbers using various arithmetic and rounding operations. Some examples:
=ceil(rand()*1000,100) // Generate a number between 100 and 1000 in multiples of 100
=pick(ceil(rand()*5), '12', '15', '27', '3', '44') // Picks randomly from these 5 values.
I suppose you can do something like this.
mapping load * inline [
let vNoOfNumbers = NoOfRows('MapNumbers');
load applymap('mapNumbers',ceil(rand()*'$(vNoOfNumbers)'),null()) as RandomSelectedNumber
If you want to read the possible numbers from a file you would do:
mapping load rowno() as ID, Number from File.