Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I'm trying to create a flag for Sales > 0 and < 0 as below in the script.
But it is displaying as Invalid Expression on reload.
Can someone help me what went wrong?
LOAD
ID,
Sales,
If(Sum(Sales) > 0, 1,0) as SalesFlag;
SQL SELECT * FROM ......
In case you only want a flag per individual sales value / row of your source table, one solution might be:
LOAD ID,
Sales,
Sign(Sales) as SalesFlag;
SQL SELECT * FROM ......
or
LOAD ID,
Sales,
If(Sales, 1, 0) as SalesFlag;
SQL SELECT * FROM ......
hope this helps
regards
Marco
Try this:
Table:
LOAD ID,
Sales;
SQL SELECT * FROM ......
Left Join (Table)
LOAD ID,
If(Sum(Sales) > 0, 1, 0) as SalesFlag
Resident Table
Group By ID;
To use an aggregation expression in your load script, you must include a group by clause.
sunindia shows how you can do this.
Can we include SET ANALYSIS in above Sum(Sales) in script window?
Also the above is still throwing error
Seems like i have the SQL statement and it is not supporting to use it.
I will use Preceding Load before this and see if i can achieve this?
I tried different way, it is not working, Can someone help me to achieve this using SET expression in script window?
I tried different way, it is not working, Can someone help me to achieve this using SET expression in script window?
There is not set analysis in the script. You can use ifs or Where statements to restrict things. Do you know what you are restricting?
I'm basically restricting the sales <0 and > 0
In case you only want a flag per individual sales value / row of your source table, one solution might be:
LOAD ID,
Sales,
Sign(Sales) as SalesFlag;
SQL SELECT * FROM ......
or
LOAD ID,
Sales,
If(Sales, 1, 0) as SalesFlag;
SQL SELECT * FROM ......
hope this helps
regards
Marco