Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Function "if" calculate in then

Hi guys,

I don't understand How I can calculate some examples. See below.

if (a>0, 'b*0,1', 'b*0,15')

I see result b*0,1, but I want calculate it. For example 3*0,1 and result = 0,3.

How I can do it? Help me, please.

Many thanks,

Yuriy

1 Solution

Accepted Solutions

Re: Function "if" calculate in then

Whats the condition your looking for ? could you please explain bit more

if(a>0 , b*0.1 , b*0.15 )

so this evaluate like this ....

if a >0 , then b multiple 0.1 and if a not >0 then b multiple 0.15

Hope this helps you

8 Replies
oknotsen
Honored Contributor III

Re: Function "if" calculate in then

Remove the quotes.

Replace the comma by a dot. Only a hand full of countries use the comma as a decimal separator, the rest of the world (or at least the programming world) uses a dot. Confusing, I know; I live in a country that uses the comma.

May you live in interesting times!

Re: Function "if" calculate in then

here is an example

if(condition , then , else)

The three parameters condition, then and else are all expressions. The first one, condition, is interpreted logically. The two other ones, then and else, can be of any type. They should preferably be of the same type. If condition is true, the function returns the value of the expression then. If condition is false, the function returns the value of the expression else.

Example:

if( Amount>= 0, 'OK', 'Alarm' )

Not applicable

Re: Function "if" calculate in then

Thanks, but it doesn't work.

I have the same result b*0.1, but I want receive 0.3 (b*0.1=3*0.1).

Have you any another ideas?

Re: Function "if" calculate in then

Whats the condition your looking for ? could you please explain bit more

if(a>0 , b*0.1 , b*0.15 )

so this evaluate like this ....

if a >0 , then b multiple 0.1 and if a not >0 then b multiple 0.15

Hope this helps you

Not applicable

Re: Function "if" calculate in then

Thank you a lot! It works.

Many thanks,

Yuriy

oknotsen
Honored Contributor III

Re: Function "if" calculate in then

So what I suggest does not work, but when Avinash suggests (in my opinion) exactly the same it does all of a sudden work?

Could you explain the difference as I am probably overlooking the obvious.

May you live in interesting times!

Re: Function "if" calculate in then

okg‌ probably the example made a difference but yes yours and mine suggestion are one and the same

Not applicable

Re: Function "if" calculate in then

Yes, of course. Example help me. I was careless and forgot remove quotes, that's why I had a negative result(((

Of course, you answer is right and the same.

Sorry for my careless. Thank you for help.