Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi...!!!
Please suggest how to derive
PRE SALES
DIFF
PER(%)
as per the below mentioned details and my data only contains 2 fields i.e YEAR and SALE
YEAR | SALE | PRE SALES | DIFF | PER(%) |
2001 | 2000 | |||
2002 | 2500 | 2000 | 500 | 25 |
2003 | 4300 | 2500 | 1800 | 72 |
2004 | 2000 | 4300 | -2300 | -53.48837209 |
2005 | 1000 | 2000 | -1000 | -50 |
2006 | 5000 | 1000 | 4000 | 400 |
2007 | 4678 | 5000 | -322 | -6.44 |
2008 | 8623 | 4678 | 3945 | 84.33091065 |
2009 | 7290 | 8623 | -1333 | -15.45865708 |
2010 | 4726 | 7290 | -2564 | -35.17146776 |
2011 | 8564 | 4726 | 3838 | 81.21032586 |
PRE SALES | PERVIOUS YEAR SALES |
DIFF | DIFFERENCE OF CURRENT SALES AND PRE SALES |
Thanking You
Vinayagam
RESULT
SCRIPT
Source:
load * inline [
YEAR, SALE
2001, 2000
2002, 2500
2003, 4300
2004, 2000
2005, 1000
2006, 5000
2007, 4678
2008 ,8623
2009, 7290
2010, 4726
2011, 8564
];
Table:
NoConcatenate
load
YEAR, SALE,
peek(SALE) as PREVSALE,
SALE - peek(SALE) as DIFF,
(SALE - peek(SALE)) / peek(SALE) as DIFF%
Resident
Source
order by YEAR;
DROP Table Source;
Hi,
Use Peek() and previous function for this
Thanks & Regards
RESULT
SCRIPT
Source:
load * inline [
YEAR, SALE
2001, 2000
2002, 2500
2003, 4300
2004, 2000
2005, 1000
2006, 5000
2007, 4678
2008 ,8623
2009, 7290
2010, 4726
2011, 8564
];
Table:
NoConcatenate
load
YEAR, SALE,
peek(SALE) as PREVSALE,
SALE - peek(SALE) as DIFF,
(SALE - peek(SALE)) / peek(SALE) as DIFF%
Resident
Source
order by YEAR;
DROP Table Source;
Hi,
Dimension: Year
Expression for Sales: sum(SALE)
Expression for Presales: above(sum(SALE),1)
Hi.
You can use above(Sum(SALE),1) function to get this result.
Here is an example
Hi,
Load your table some thing like below
Temp:
LOAD * Inline
[
YEAR, SALE
2001, 2000
2002, 2500
2003, 4300
2004, 2000
2005, 1000
2006, 5000
2007, 4678
2008, 8623
2009, 7290
2010, 4726
2011, 8564
];
Temp2:
load
YEAR,
SALE,
Previous(SALE) as Presale
Resident Temp;
DROP Table Temp;
Data:
load
YEAR,
SALE,
Presale,
SALE-Presale as diff
Resident Temp2;
DROP Table Temp2;
Hope this helps
Thanks
Hi,
Here is updated one lets see
Temp:
LOAD * Inline
[
YEAR, SALE
2001, 2000
2002, 2500
2003, 4300
2004, 2000
2005, 1000
2006, 5000
2007, 4678
2008, 8623
2009, 7290
2010, 4726
2011, 8564
];
Temp2:
load
YEAR,
SALE,
Previous(SALE) as Presale
Resident Temp;
DROP Table Temp;
Data:
load
YEAR,
SALE,
Presale,
SALE-Presale as Diff,
(SALE-Presale) / Presale as Diff%
Resident Temp2;
DROP Table Temp2;
Hope this helps
Thanks & Regards
Thanks ton...!!!!
Thanks ton...!!!!