Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
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

18 Replies
gandalfgray
Specialist II
Specialist II

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

Anonymous
Not applicable
Author

thanks.

but i still get this:

bild_version3.JPG

se all the decimal still?

gandalfgray
Specialist II
Specialist II

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

Anonymous
Not applicable
Author

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?

gandalfgray
Specialist II
Specialist II

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!

Anonymous
Not applicable
Author

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!

Anonymous
Not applicable
Author

and here's the qvw

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

Anonymous
Not applicable
Author

Thanks that did the trick!