Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I recently started working with set Analysis.
I found out 2 different syntax for that.
1. Sum({<Region={'North'}>}Sales)
2. Sum(${<Region={'North'}>}Sales)
Why $ sign we use in 2nd statement. what is use of that? If it throws same answer why we use it.
Thanks in adv.
$ denotes the default state.
Both expression differ when you are using alternate states, then the first expression without $ refers to the inherited state (which could be different from default).
Thanks Stefan Wuhl, is it only thing that we use $ in it? or something else ?
Hi Narendra,
As set analysis usually refers to current selections, if there is not any set in a explicit way, the default is current selections. I think is a way of prevent errors or make it simple.
Regards,
H
I am really sorry that I unable to understand these terms as I am new to set analysis. Would you please elaborate with example. Thanks in Advance
from Help
Dollar-sign expansions are definitions of text replacements used in the script or in expressions. This process is known as expansion - even if the new text is shorter. The replacement is made just before the script statement or the expression is evaluated. Technically it is a macro expansion.
A macro expansion always begins with '$(' and ends with ') ' and the content between brackets defines how the text replacement will be done. To avoid confusion with script macros we will henceforth refer to macro expansions as dollar-sign expansions.
Note!
Macro expansion is unrelated to script macros (VB or Java script defined in the script module).
Note!
A dollar-sign expansion is limited in how many macro expansions it can calculate. Any expansion over 1000 will not be calculated!
When using a variable for text replacement in the script or in an expression, the following syntax is used:
$( variablename )
$( variablename) expands to the value in variablename. If variablename does not exist the expansion will be the empty string.
For numeric variable expansions, the syntax $( variablename ) will generate a number using the regional decimal separator, i.e. for many countries a decimal comma. Such an expansion should not be used for numbers inside the script since these must use decimal point. Instead the expansion $(# variablename ) should be used. (Note the hash sign). It always yields a valid decimal-point representation of the numeric value of variablename, possibly with exponential notation (for very large/small numbers). If variablename does not exist or does not contain a numeric value, it will be expanded to 0 instead.
Example:
After execution of the following script:
SET DecimalSep=',';
LET X = 7/2;
$(X ) will expand to 3,5 while $(#X ) will expand to 3.5.
Examples:
set Mypath=C:\MyDocs\Files\
...
load * from $(MyPath)abc.csv;
set CurrentYear=1992;
...
select * from table1 where Year=$(CurrentYear);
Parameters can be used in variable expansions. The variable must then contain formal parameters, such as $1, $2, $3 etc. When expanding the variable, the parameters should be stated in a comma separated list.
Examples:
set MUL=’$1*$2’;
set X=$(MUL(3,7)); // returns '3*7' in X
let X=$(MUL(3,7)); // returns 21 in X
If the number of formal parameters exceeds the number of actual parameters only the formal parameters corresponding to actual parameters will be expanded. If the number of actual parameters exceeds the number of formal parameters the superfluous actual parameters will be ignored.
Examples:
set MUL=’$1*$2’;
set X=$(MUL); // returns '$1*$2' in X
set X=$(MUL(10)); // returns '10*$2' in X
let X=$(MUL(5,7,8)); // returns 35 in X
The parameter $0 returns the number of parameters actually passed by a call.
Example:
set MUL='$1*$2 $0 par';
set X=$(MUL(3,7)); // returns '3*7 2 par' in X
Expressions can be used in dollar-sign expansions. The content between the brackets must then start with an equal sign:
$( =expression )
The expression will be evaluated and the value will be used in the expansion.
Example:
$(=Year(Today())); // returns e.g. '2008'
$(=Only(Year)-1); // returns the year before the selected one
File inclusions are made using dollar-sign expansions. The syntax is then:
$( include=filename )
The above text will be replaced by the content of the file specified after the equal sign. This feature is very useful when storing scripts or parts of scripts in text files.
Example:
$(include=C:\Documents\MyScript.qvs);