21.01.2013 Views

QlikView Reference Manual.pdf - QlikCommunity - QlikView

QlikView Reference Manual.pdf - QlikCommunity - QlikView

QlikView Reference Manual.pdf - QlikCommunity - QlikView

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Note!<br />

A dollar-sign expansion is limited in how many macro expansions it can calculate. Any expansion over<br />

1000 will not be calculated!<br />

Dollar-Sign Expansion Using a Variable<br />

When using a variable for text replacement in the script or in an expression, the syntax<br />

$( variablename )<br />

is used. $(variablename) expands to the value in variablename. If variablename does not exist the expansion<br />

will be the empty string.<br />

For numeric variable expansions, the syntax<br />

$( variablename )<br />

is used. $( variablename ) always yields a legal decimal-point reflection of the numeric value of variablename,<br />

possibly with exponential notation (for very large/small numbers). If variablename does not exist<br />

or does not contain a numeric value, it will be expanded to 0 instead.<br />

Example:<br />

Examples:<br />

After execution of the following script:<br />

SET DecimalSep=',';<br />

LET X = 7/2;<br />

$(X ) will expand to 3,5 while $(#X ) will expand to 3.5.<br />

set Mypath=C:\MyDocs\Files\<br />

...<br />

load * from $(MyPath)abc.csv;<br />

set CurrentYear=1992;<br />

...<br />

select * from table1 where Year=$(CurrentYear);<br />

Dollar-Sign Expansion with Parameters<br />

Parameters can be used in variable expansions. The variable must then contain formal parameters, such as $1,<br />

$2, $3 etc. When expanding the variable, the parameters should be stated in a comma separated list.<br />

Examples:<br />

set MUL=’$1*$2’;<br />

set X=$(MUL(3,7)); // returns '3*7' in X<br />

let X=$(MUL(3,7)); // returns 21 in X<br />

If the number of formal parameters exceeds the number of actual parameters only the formal parameters corresponding<br />

to actual parameters will be expanded. If the number of actual parameters exceeds the number of<br />

formal parameters the superfluous actual parameters will be ignored.<br />

Examples:<br />

set MUL=’$1*$2’;<br />

set X=$(MUL); // returns '$1*$2' in X<br />

set X=$(MUL(10)); // returns '10*$2' in X<br />

let X=$(MUL(5,7,8)); // returns 35 in X<br />

280

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!