Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
How to create a column(G) using multiple if condition .
Condition: S='a' and P<=3,'Y' or else 'N'
S='b' and P<= 5, 'N' or else 'O'
Source data:
S | P |
a | 2 |
a | 2 |
b | 3 |
b | 5 |
Required output:
S | P | G |
a | 1 | Y |
a | 4 | N |
b | 6 | O |
b | 5 | N |
Thanks,
Krishna
How is Column P changing? For the column G, try this
If(S = 'a',
If(P <= 3, 'Y', 'N'),
If(S = 'b',
If(P <= 5, 'Y', 'O'))) as G
Hi Try this:
=if(
S= 'a' and P<= '3' , 'Y',
If(S= 'a' and P> '3', 'N',
If(S= 'b' and P<= '5', 'N',
'0'
)))
Please like or mark if correct 🙂
Hi,
one solution could be also:
table1:
LOAD *,
Pick(Match(S,'a','b'),
If(P<=3,'Y','N'),
If(P<=5,'N','O')) as G;
LOAD Pick(Ceil(Rand()*2),'a','b') as S,
Ceil(Rand()*8) as P
AutoGenerate 10;
hope this helps
regards
Marco