Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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
thanks.
but i still get this:
se all the decimal still?
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
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?
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!
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!
and here's the qvw
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
Thanks that did the trick!