Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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!

table.JPG

1 Solution

Accepted Solutions
gandalfgray
Specialist II
Specialist II

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

View solution in original post

18 Replies
SunilChauhan
Champion
Champion

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

or

you can use

num(Expression,'#.##')

hope this helps u

Sunil Chauhan
Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

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.

SunilChauhan
Champion
Champion

can u share sample

Sunil Chauhan
Anonymous
Not applicable
Author

here you go

gandalfgray
Specialist II
Specialist II

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.

I suggest you apply the rounding in the load script already.

hth/gg

Anonymous
Not applicable
Author

thanks!

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

this is what the previous table looks like after rounding:

exemple_variable.JPG

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.

gandalfgray
Specialist II
Specialist II

No idea Annika.

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

/gg

Anonymous
Not applicable
Author

here it is