18 Replies Latest reply: Aug 30, 2011 7:02 AM by Annika Palm

# to many decimals that can't be removed?

Hi,

I'm strugguling with a decimal-problem. In my source data i have numbers with 2 decimals (source data is an xml-file and i have checked it a 100 times, only 2 decimals). ok.

In my senario i store one of these numbers as a variable and then in one of my chart i want to color cells according to weather or not the number is higer, lower or equals that variable number. Piece of cake i thougt. But. if i subtract my set analysis statment (which contains numbers from the same field the variable is from) from the variable i end up with a differ.

I've attaced my chart (straight table) so that you can see the expresssion.

I've tried everything so that's why i need you guys.

Thanks!

• ###### to many decimals that can't be removed?

go to chart properties>number->check radio Fix to-> type 2

or

you can use

num(Expression,'#.##')

hope this helps u

• ###### to many decimals that can't be removed?

nope. none of them work. i still get "-0.00" in the subtraction.

• ###### to many decimals that can't be removed?

i've tried the roundfunction tow but i don't know how to write that one when you want to round to two decimals. the example only shows one.

• ###### to many decimals that can't be removed?

can u share sample

• ###### Re: to many decimals that can't be removed?

Hi Annika

Round works like this:

(I am using pi() in the samples below which gives the value of pi as the number to round)

To round to four decimals:

round(pi(),  0.0001)

to round to three decimals:

round(pi(),  0.001)

to round to two decimals:

round(pi(),  0.01)

and so on.

hth/gg

• ###### Re: to many decimals that can't be removed?

thanks!

but when i do this, my variables doesn't work for some reason.

this is what the previous table looks like after rounding:

as you can se, the header "4,12" is the variable but i doesn't show on the other rows as it did before. why is that?

I make this variable with the peek function.

• ###### Re: to many decimals that can't be removed?

No idea Annika.

Publish the new qvw, containing that table, and I can have a look

/gg

• ###### Re: to many decimals that can't be removed?

here it is

• ###### Re: to many decimals that can't be removed?

Hi

The problem is that in calculations, expressions etc QV uses . as the decimal separator.

(the setting of DecimalSep seems to have no effect on this)

change all your rate  variable assignments like this:

from:

Let SBAB3mån = peek('rate', 0, 'tmpBankSBAB');

to:

Let SBAB3mån = replace(peek('rate', 0, 'tmpBankSBAB'),',','.'); // replace , with .

hth/gg

• ###### Re: to many decimals that can't be removed?

thanks.

but i still get this:

se all the decimal still?

• ###### Re: to many decimals that can't be removed?

Hi again

If you are concerened just with the look in tables/charts etc just set the Number Format Settings for that expression as you want it to look (Fixed to 2 decimals, maybe).

If you want to make comparisons you can't check for equality/inequlity, you need to check that the absolute value of the difference is within the limit of your choice:

fabs(4.12-sum(something...))<0.00001  (or something like that)

/gg

• ###### Re: to many decimals that can't be removed?

no, unfortunately that's not my concern. i use this expressions to state what color one cell should be. i've tried the fabs thing too but i still doesn't work. it's so wierd! bug?

• ###### to many decimals that can't be removed?

and what are the rules yu want to use  for applying the cell colors?

Explain that, and post a  .qvw and I have a look!

• ###### Re: to many decimals that can't be removed?

here's the expression

if(sum({\$<timename={'3 mån'}>} rate)-\$(SBAB3mån)=0, Yellow(),

if(sum({\$<timename={'3 mån'}>} rate)>0,

if(sum({\$<timename={'3 mån'}>} rate)>\$(SBAB3mån), green(), red()), white())

)

i'll post you the qvw as soon as i can!

• ###### Re: to many decimals that can't be removed?

and here's the qvw

• ###### Re: to many decimals that can't be removed?

Hi Annika

Use fabs() and check against a reasonable limit, see below.

See the attached qvw.

I changed the background color, and text color of the first column, to test. It works as far as I can see.

This is the Background Color expression:

if(fabs(sum({\$<timename={'3 mån'}>} rate)-\$(SBAB3mån))<0.0001, Yellow(),

if(sum({\$<timename={'3 mån'}>} rate)>0,

if(sum({\$<timename={'3 mån'}>} rate)>\$(SBAB3mån), green(), red()), white())

)

hth/gg

• ###### Re: to many decimals that can't be removed?

Thanks that did the trick!