Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear QV community
unfortunately I can not find suitable solution for my problem in the forum.
How can I set variables in the load block ? Thank you!
Here a pseudocode of my intension !
<qlikview script>
MyTable:
LOAD models,
if( product= 'white', productcode = '7231', productcode='7000' ) as productColor,
price,
quantity
FROM
items.csv (txt, codepage is 1252, embedded labels, delimiter is ';', msq);
</qlikview script>
Hi
The short answer is that you cannot set variable values within a LOAD statement. You can, however, interrogate the loaded data after loading and set a variable based on the outcome. For example:
MyTable:
LOAD models,
productColor,
price,
quantity
FROM
items.csv (txt, codepage is 1252, embedded labels, delimiter is ';', msq);
tmp:
LOAD Count(productColor) As WhiteCount
Resident MyTable;
Let productcode = (If(Peek('WhiteCount') > 0, '7231', ''));
...
Drop Table tmp;
Hope that helps
Jonathan
Hi
The short answer is that you cannot set variable values within a LOAD statement. You can, however, interrogate the loaded data after loading and set a variable based on the outcome. For example:
MyTable:
LOAD models,
productColor,
price,
quantity
FROM
items.csv (txt, codepage is 1252, embedded labels, delimiter is ';', msq);
tmp:
LOAD Count(productColor) As WhiteCount
Resident MyTable;
Let productcode = (If(Peek('WhiteCount') > 0, '7231', ''));
...
Drop Table tmp;
Hope that helps
Jonathan