Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
i'm trying to to create if-else in LOAD in script level.
LOAD
ID,
(A+B+C) as F1;
SQL SELECT *
FROM TABLE
the if-else would be placed at the calculation,
column F1 = if (a+b+c) > 20 then set F1 as DIGIT 1 else 0 so that i can use it to count.
Column F2 = if (a+b+c) < 20 then set F2 as DIGIT 1 else 0....
so in the end, i'd have 3 column, ID, F1, F2
Hi
Try the following
LOAD
ID,
IF(A+B+C > 20 , 1 , 0) AS F1,
IF(A+B+C < 20 , 1, 0) AS F2;
SQL SELECT * FROM TABLE;
LOAD
ID,
if ((A+B+C)>20,1) as F1,
if ((A+B+C)<20,1) as F2;
SQL SELECT *
FROM TABLE;
/Michael
Thanks for the solution, it works for me.
But it wont work if i'm using the new name after the AS
Load
Field1 as Fieldtext
if (Fieldtext = abc, .........
i had to use...Field1 instead of Fieldtext. any idea why?
Load
Field1 as Fieldtext
if (Field1 = abc, .........
the reason is that Field1 could be a very long formula or IF ELSE statment, so it'd be good if i can just use Fieldtext as a substitute..
If FieldName is a long field or a formula you can replace it by a variable such as
LET MyFieldName='LongFieldNameBlablabla';
Thenin your Load
LOAD
IF("$(MyFieldName)" = abc, ....) then it should work.
Rgds,
Sébastien
You can stack LOAD statements like this:
tablename:
LOAD Field3;
LOAD if(Field2 = 'def', ...) as Field3;
LOAD if(Field1 = 'abc', ...) as Field2 FROM....;
- Ralf