Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
sivarajs
Specialist II
Specialist 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

6 Replies
sunny_talwar

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

PrashantSangle

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.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Peter_Cammaert
Partner - Champion III
Partner - Champion III

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
Specialist II
Specialist II
Author

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

Anil_Babu_Samineni

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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Peter_Cammaert
Partner - Champion III
Partner - Champion III

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