Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I want a field year and sales. I want to create a new field accumulatesales which should be sum of current year sales + previous year sales.
How to create this new field in the script?
Please provide your suggestions.
Thanks,
SV
Hi,
Use this.
Table_Sales:
LOAD year,
sum(sales) as sales,
from ****YOUR SOURCE**;
left join(Table_Sales)
LOAD year,
sum(sales) +Previous(sales) as New_Sales
Resident
Temp_Sales
order by year asc;
it depends on your data
this could be a solution
z:
load * inline [
Year, Sales
2010, 100
2011, 110
2012, 120
2013, 130
2014, 140
2015, 100
];
zz:
load Year, Sales + Previous(Sales) as TwoYearSales Resident z order by Year;
test1:
load * inline [
year, Sales
test2:
load year,
if(IsNull(Sales + Previous(Sales)),Sales,(Sales + Previous(Sales))) as PreviousSales
Resident z Order by Year;