Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

Qlik Sense if condition with decimal weird behavior

Hi all,

I have little transformation on my app very simple which works againg  Home_Flag  = 1 or 0 (numeric) and I noticed that it works strangely if I use this expression:

if(Home_Flag = 0,'No','Yes')  putting Yes for some data where Home_Flag = 0

it happening while working on big dataset (500K+ rows).

I fixed this by using:

if(Home_Flag > 0,'Yes','No')


Not sure what is wrong with first one, I DID played with quotes around "0" and it doesn't make any diff.  I used it to add column in my simple table in Q Sense.


Thanks

M

1 Solution

Accepted Solutions
Not applicable

Re: Qlik Sense if condition with decimal weird behavior

I think that is because when you write equal to 0 it looks for exact zero. If there is any decinal value like 0.0000002 it will go to else condition. It is always better to use >=0 if you are looking for positive value or with >0 and < 2 something like that so that it will take care of decimal values.

5 Replies
Not applicable

Re: Qlik Sense if condition with decimal weird behavior

I think that is because when you write equal to 0 it looks for exact zero. If there is any decinal value like 0.0000002 it will go to else condition. It is always better to use >=0 if you are looking for positive value or with >0 and < 2 something like that so that it will take care of decimal values.

lakshmikandh
Not applicable

Re: Qlik Sense if condition with decimal weird behavior

May be your home_flag what some values like 0.000XXX which is not exactly zero, that is why it works with > operator.

jontydkpi
Not applicable

Re: Qlik Sense if condition with decimal weird behavior

I agree - it seems likely that your zero is not exactly zero (even though it may display as 0). You could also try

=If(Round(Home_Flag) = 0, 'No', 'Yes')

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Re: Qlik Sense if condition with decimal weird behavior

Thanks Jaydeep, Lakshmikandh and Jonathan, I'm doing more work to clarify this, still have itching about this,  alas can't give stars to all you..

Best

M

Not applicable

Re: Qlik Sense if condition with decimal weird behavior

I did more testing and see that it's indeed  0 or 1, this load doesn't brings any rows, so it might be something else including my errors.

LOAD

.....

WHERE FLAG <> 1 and FLAG <> 0