Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am looking for a way to store a decimal number into a variable under German language settings so that the variable can be used in a function expecting a numerical/decimal argument later. The catch with German language settings is that the decimal separator is ',' (thousand separator is '.'). QlikView seems to mix up function arguments separator and decimal separator.
Example 1 (English language settings, works):
SET ThousandSep=',';
SET DecimalSep='.';
SET TimestampFormat='MM/DD/YYYY hh:mm:ss[.fff]';
LET varNow = Now();
LET varTimestamp = Timestamp($(#varNow));
TRACE varTimestamp $(varTimestamp);
TRACE #varTimestamp $(#varTimestamp);
Output:
varNow: 07/20/2010 16:35:37
#varNow: 40379.691400463
varTimestamp 07/20/2010 16:35:37
#varTimestamp 40379.691400463
Example 2 (German launguage settings, does not work):
SET ThousandSep='.';
SET DecimalSep=',';
SET TimestampFormat='DD.MM.YYYY hh:mm:ss[.fff]';
LET varNow = Now();
LET varTimestamp = Timestamp($(#varNow));
TRACE varTimestamp $(varTimestamp);
TRACE #varTimestamp $(#varTimestamp);
Output:
varNow: 20.07.2010 16:47:33
#varNow: 40379,6996875
varTimestamp 6996875
#varTimestamp 40379
The problem seems to be that $(#varNow) resolves to 40379,6996875 instead of 40379.6996875. I tried to do a Replace($(#varNow), ',', '.'), which - apart from being ugly - did not work either on account of the ',' in the decimal string being interpreted as function argument separator again.
Could someone please point me to the obvious solution I failed to see? Thanks!
I just accidentally found out that apparently you can call variables directly by name in the script, i.e. just "varFoo" instead of "$(varFoo)" or "$(#varFoo)". That seems to circumvent the separator-changing business.
I also thought that the problem in my example in the above post might be that Now() gives a type dual variable. Therefore I reproduced a much easier example from the manual:
SET DecimalSep = ',';
LET var = 7 / 2;
TRACE $(var);
TRACE $(#var);
The manual states that in this case $(var) should resolve to '3,5', whereas $(#var) should resolve to '3.5'. Yet I get:
3,5
3,5