Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
In the script, is it possible to generate random data in a field named "X" for example, from the VALUES of another field named "Y"?
Yes, you can decide the rule to generate random values according to the type of the starting field.
If the field is numeric you can use Rand(function), if the field is a string you can use the first char numerical value, if the field is a date you can use its numerical representation
maybe sth like
Pick(Ceil(3*Rand()),'A','B','C') as MyRandomField1,
or with the field Y
Round(1000*Rand()*Rand()*Y) as MyRandomField2,
The case is the following:
i have the field Y having the values as in the screenshot:
I need to create a new table with the following:
LOAD id,
<random values from the values in Field Y> as Field X
[.....]
Hi what type of random value do you need like String or number type.
In QLikview we can generate the random data , but we need a pattern to generate the random data.
What is ur assumption or pattern for FieldX with respect FieldY.
Generally we use rand function to generate the number type.
Ceil(RAND()*100)
Thanks, very useful. What in case I want to generate the values in the ratio of my choice, e.g., I am generating 1000 rows with values A, B, C and I want to populate 30% with value A, 50% with value B and 20% with value C. Can I do that?
I am referring to this code: Pick(Ceil(3*Rand()),'A','B','C') as MyRandomField1
Hi,
maybe one solution might be:
table1:
LOAD RecNo() as ID, * Inline [
FieldY
A344534
B346564
C345645
D457675
E435645
F352356
G435756
];
table2:
LOAD ID,
FieldValue('FieldY',Ceil(Rand()*FieldValueCount('FieldY'))) as FieldX
Resident table1;
hope this helps
regards
Marco