Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Trouble with decimal settings ... again


Hi,

I have a value that I have calculated in my script as >> 24,93051 <<.

Script settings are:

>>>>>>>>>>>>>>

SET ThousandSep='.';
SET DecimalSep=',';
SET MoneyThousandSep='.';
SET MoneyDecimalSep=',';

<<<<<<<<<<<<<<<<<<<<<

So the comma should be used as decimal_separator - I know that QlikView calculates with the opposed settings internally. Right?

So when I type

>>  round([that value], '0.0001' <<

should not that round the output to four decimals?

Well, it doesn't. Instead this gives me 0.0025 or something.

So what do I have to do to get this value rounded to four decimals?

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
datanibbler
Champion
Champion
Author

Hi Avinash,

finally I think I have made it - though I don't quite understand.

I had a few variables, all numeric, all with the "comma" and a few values from tables to multiply with those, all numeric, all with the "comma" - still, at the end of it, I had two identical-looking values, but the IF_query told me they were not equal.

Now I did the same to the final values once again - I used first the Replace() (to swap the "comma" with the "dot") and then num# to get a valid numeric value again - and now the query tells me they are equal.

Eventually I have to find out what is the root cause of this strange happening - else I will have the same kind of trouble again and again. It must be connected to the fact that the basic settings in Excel are in German formatting - the "comma" as separator - I cannot change those, I have no admin_rights on my machine, so I have mirrored those in the SET commands in my script, but the internal calculations of QlikView are done the other way round.

Well, I guess this is solved. Thank you all!

View solution in original post

30 Replies
marcus_sommer

Hi DataNibbler,

you could use num() to format your number.

- Marcus

sunny_talwar

What you have seems to work for me:

SET ThousandSep='.';

SET DecimalSep=',';

SET MoneyThousandSep=',';

SET MoneyDecimalSep='.';

SET MoneyFormat='$#,##0.00;($#,##0.00)';

SET TimeFormat='h:mm:ss TT';

SET DateFormat='M/DD/YYYY';

SET TimestampFormat='M/DD/YYYY h:mm:ss[.fff] TT';

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

Table:

LOAD *,

  Round(Value, '0.0001') as NewValue;

LOAD * Inline [

Value

24,93051

] (delimiter is '|');

Output:

Capture.PNG

avinashelite

try like this:

num(value,'###0.0000')

rubenmarin

Hi DataNibbler,

If I use =Round('24,93051', 0.0001) ir returns 24,9305


Remove the single quotes in 0.0001 to check if it works.

datanibbler
Champion
Champion
Author


Hi Avinash,

that gives me the strangest result of all - my value now is

>> 115,69281 <<

When I go like that with the num() function, what I get is

>> 116.##0,0000 <<

What is that supposed to be?

datanibbler
Champion
Champion
Author

Hi Ruben,

do I have to put the value that I want to round in quotes?

I'll try that.

rubenmarin

Hi, not sure, if you're using the value as a variable maybe it's using the comma, in something like

Round(24,93051, 0.0001)

I used the single quote as delimiter for the number, without single quotes the comma used as decimal separator will be used as a parameter separator, wich can surely lead to some issue.



datanibbler
Champion
Champion
Author

Hi Ruben,

that sounds logical. In fact I have had that issue elsewhere - that functions interpret the comma as the separator between different parameters.

The value is calculated in the LOAD statement. I use a variable (multiplied with a field from the table) - the variable has the dot as decimal_separator, but the field_value has the comma. That seems to cause the issue.

OK - when I insert a PRECEDING LOAD with a REPLACE() function, I can round it all right. let's see ...

sasiparupudi1
Master III
Master III

Round(Num#(Value, '#,##0.#'),0.0001)