Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
How to write multiple if condition here for
if s1=a and s2=e condition=yes
s1=b and s2=f condition=yes
s1=c and s2=g condition=yes
s1=d and s2=h condition= yes
for remaining all condition=n0
ID | S1 | S2 |
1 | a | e |
2 | b | f |
3 | c | g |
4 | d | h |
5 | d | k |
6 | d | l |
output
ID | condition |
1 | yes |
2 | yes |
3 | yes |
4 | yes |
5 | No |
6 | No |
Hi
Try this as mesure
if(S1='a' and S2 ='e'
or S1='b' and S2='f'
or S1='c' and S2='g'
or S1='d' and S2='h',
'YES','NO')
Or in the script :
condition:
load * ,
if(S1='a' and S2 ='e'
or S1='b' and S2='f'
or S1='c' and S2='g'
or S1='d' and S2='h',
'YES','NO') as Condition;
load *inline [
ID, S1, S2
1, a, e
2, b, f
3, c, g
4, d, h
5, d, k
6, d, l
](delimiter is ',');
With a slight tweak by wrapping the OR statements with brackets you may apply the suggestion from @brunobertels. Another possibility might be to query both fields together, for example like:
if(match(s1 & '|' s2, 'a|e', 'b|f', ...), 'yes', 'no')
By a larger number of combinations it might be more suitable to load them within a mapping table and querying the results from there.
- Marcus