Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Guys,
I am new to Qk sense and need some help with wiring a Case statement.
I am looking to change SQL syntax to Qlik
case when ('feild1' NE " ") and ('Feild2' NE " ") and ('feild3' NE " " or field4 NE " ") and ('feild5' NE " " or 'field6' NE . ) and ('field7' NE 12345)then yes else no
(if(feild1 <>' ',
if(feild2 > '12345'
IF((feild3 <> ' ' OR field4 <> ' '),
IF((feild5 <> ' ' OR field6 <> ' '),
'YES',NO')))))
TIA
Hi,
Try this:
//Load Temp table
// For first row, "Flag" should be Yes and second row it should be No
Test:
load * inline
[F1, F2, F3, F4, F5, F6, F7
1,2,3,4,5,6,7
' ',' ',' ',' ',' ','.',12345];
//Resident load
load
F1, F2, F3, F4, F5, F6, F7,
// Case Statement Equivalent
if((F1<>' ' and F2<>' ' and (F3<>' ' or F4<>' ') and (F5<>' ' or F6<>'.') and F7<>12345),'Yes','No') as Flag
resident Test;
Result:
F1 | F2 | F3 | F4 | F5 | F6 | F7 | Flag |
1 | 2 | 3 | 4 | 5 | 6 | 7 | Yes |
. | 12345 | No |
Hope this helps.
Manas
Try If loop
Load
If ('feild1' NE " ") and ('Feild2' NE " ") and ('feild3' NE" " or field4 NE " ") and ('feild5' NE " " or 'field6' NE . ) and('field7' NE 12345),'yes','no' ) as Value,
...
FROM ...