Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
joioan
Contributor III
Contributor III

where clause with if condition (script attached)

Hello, wishes for  a happy new year!

Question.

Does a where clause like that work?

where Key>
if(Field='123' ,2001*12,
if(match(Field,'456','789','101112'),2002*12,
if(match(Field,'131415','161718','192021'),2003*12,
if(match(Field,'222324,'252627') ,2004*12,
if(match(Field,'282930') ,2005*12))))) ;
 
 
Labels (2)
2 Replies
Ahidhar
Creator III
Creator III

I don't think it will work better to have if statements before where clause

Aditya_Chitale
Specialist
Specialist

the if() condition that you have included have multiple outputs thus the where clause won't have a fixed value to compare the "Key" field with and restrict data accordingly.

Create a new field in table script and use this field to compare with Key field and allocate Flags on basis of that and use this Flag in where condition.
 
Refer below screenshot for script and output:
 
Aditya_Chitale_0-1704283783123.png

 

Output:

Aditya_Chitale_1-1704283806277.png

 

Regards,

Aditya