I am struggling in writing an if and statent in qlikview. I am used to doing it in sql but it's different.
I want to say
If field1 = 'yes' and field2 = 'yes' then 'match' or
If field1 = 'yes and field2 = 'no' then 'match1' or
If field1 ='no and field2 = 'yes' then 'match2'
Else 'no match'
Is this possible in qlikview.
I have tried using match and wild match but don't seem to get the and and or working
May be this
If(field1 = 'yes',
If(field2 = 'yes', 'match', 'match1),
If(field2 = 'yes', 'match2', 'no match')) as MatchFlag
With in Qlik we can achieve anything.. Perhaps this?
If(field1 = 'yes', If(field2 = 'yes', 'match', 'match1), If(field2 = 'yes', 'match2', 'no match'))
OR
If(field1 = 'yes' and field2 = 'yes', 'match', If(field1 = 'yes' and field2 = 'no', 'match1', If(field1 ='no' and field2 = 'yes', 'match2', 'no match')))
Try this may be matches with your requirement
if(field1 = 'yes' and field2 = 'yes', 'Match',
if(field1 = 'yes' and field2 = 'no','Match1',
if(field1 = 'no' and field2 = 'yes','Match2'))) as logicField
Hi Sarah,
If condition in qlik is similar to case condition in SQL. Just compare the below syntax with case condition. The code is for the script level.
case when field1 = 'yes' and field2 = 'yes' then 'match'
when field1 = 'yes and field2 = 'no' then 'match1'
when field1 ='no and field2 = 'yes' then 'match2'
Else 'no match' end in SQL
In Qlik instead of when we will keep ","(commas)
If (field1 = 'yes' and field2 = 'yes' , 'match' , ------- case when field1 = 'yes and field2 = 'yes' then 'match' when
If( field1 = 'yes and field2 = 'no' , 'match1' , ---------- field1= 'yes' and field2 ='no' then 'match1' when
If (field1 ='no and field2 = 'yes' ,'match2', -------------- field1 ='no and field2 = 'yes' then 'match2' else
'no match' ))) 'no match' end
Make sure all the open braces are closed.
Hi Sarah,
You can do this on the loading script or else UI part on the Qlikview.
On Load Script
Load
if(field1 = 'yes' and field2 = 'yes', 'Match',
if(field1 = 'yes' and field2 = 'no', 'Match1',
if(field1 = 'no' and field2 = 'yes', 'Match2','no match'))) as logicField
From Source;
On Ui part you can use but perhaps you can select suppress when values is null() but care ully you have to do this.
On UI Part
if(field1 = 'yes' and field2 = 'yes', 'Match',
if(field1 = 'yes' and field2 = 'no', 'Match1',
if(field1 = 'no' and field2 = 'yes', 'Match2','no match')))
Note:- If result not matched you can go for the multiple Preceding load or Concatenation between loads or tables
Find the attached Manual from Qlik Help