Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
i am using sum and count functions in my script, but it gives me error like invalid functions. So i just want to know is, can use use these functions in script and if yes then can some one share some syntax of using them with an if statement.
Hi,
Elaborating a bit on what Marc aptly suggests, the script should look like the following:
AllData_Temp:
LOAD Country,
CustomerID,
Value,
Discount,
NewCustomer
FROM Customers.qvd (qvd); // or whatever other data source here
// Sum and Count when NewCustomer = 1
AggregatedData:
LOAD Country,
Sum(If(NewCustomer = 1, Value, 0)) AS CountryValue,
Sum(If(NewCustomer = 1, Discount, 0)) AS CountryDiscount
RESIDENT AllData_Temp
GROUP BY Country;
DROP TABLE AllData_Temp;
Hope that helps.
Miguel
you can, but you need to do a group by with a resident table.
Hi,
Elaborating a bit on what Marc aptly suggests, the script should look like the following:
AllData_Temp:
LOAD Country,
CustomerID,
Value,
Discount,
NewCustomer
FROM Customers.qvd (qvd); // or whatever other data source here
// Sum and Count when NewCustomer = 1
AggregatedData:
LOAD Country,
Sum(If(NewCustomer = 1, Value, 0)) AS CountryValue,
Sum(If(NewCustomer = 1, Discount, 0)) AS CountryDiscount
RESIDENT AllData_Temp
GROUP BY Country;
DROP TABLE AllData_Temp;
Hope that helps.
Miguel
Works perfectly. Please mark it as answers so others can benefit....
As an addition to this.. if all you are requesting are aggregation expression results, no group by or dimension fields are required.
Data_Range:
LOAD
Min(Date) AS Earliest_Data_Date
,Max(Date) AS Latest_Data_Date
RESIDENT Fact_Table;
The post on this thread from Evan Kurowski was accidentally. In order to restore points to all participants I have copied and reinserted this comment. Thanks for your patience!