Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

sivarajs
Valued Contributor II

if condition not working

i am wondering why this simple expression is not working

if(category='NSAs',1,0)

this category is available. Any suggestion? Thanks

Tags (1)
6 Replies

Re: if condition not working

Where are you carrying this out? Script or front end?

Re: if condition not working

Hi,

it is might be because of space or case sensitive.

use wildmatch() or match()

like below

if(wildmatch(trim(category),'NSAs'),1,0)


Regards

Great dreamer's dreams never fulfilled, they are always transcended.

Re: if condition not working

What do you mean by "not working"? Is it returning nothing at all? Or just the wrong values? Or always the same value?

Do not use this code as a chart expression. Because of the possible aggregation of rows, field category may carry multiple values. Even if you cannot see some of them...

sivarajs
Valued Contributor II

Re: if condition not working

Condition fails shows 0 always but the values in the category exist

Re: if condition not working

Are you sure, The category has same Name NSAs. Because, If condition consider as Case Sensitive. Could be the case, You have only one which the value

Or else you may explain more on this

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

Re: if condition not working

What you can do is try the following:

  • create a listbox with field category
  • add an expression to this listbox (see ListBox properties->Expressions) and enter your =IF(...) code in the expression field.
  • tune the IF(...) call expression (see previous examples) until your code works as expected.

Best,

Peter