Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have following Data:
Load * Inline [
Date,Sales
12/12/2014,50
01/01/2015,100
01/02/2015,200
01/03/2015,300
01/04/2015,500
01/05/2015,600 ];
Tab1:
Load
Date as Date,
Sales as Sales,
Previous(Previous(Sales)) as PreSales
Resident Tab;
Drop Table Tab;
As of now in "Presales" column I am getting values of last 2 days but in future this value will be change for last 5 or some other number.
So please let me the dynamic way which I can use in place of previous.
May be use Peek instead of Previous where you can specify how much back you want to go.
Try this script:
Tab:
Load * Inline [
Date, Sales
12/12/2014, 50
01/01/2015, 100
01/02/2015, 200
01/03/2015, 300
01/04/2015, 500
01/05/2015, 600
];
LET vBack = -3;
Tab1:
Load Date,
Sales,
Peek(Sales, $(vBack)) as PreSales
Resident Tab;
Drop Table Tab;
Here you can set value for vBack before running the script.
Hi soha1902
you can use the code given below for the sum of previous two days.And let me know for more information
Tab1:
Load
Date as Date,
Sales as Sales,
Rangesum(Peek(Sales,-2),Previous(Sales)) as PreSales
Resident Tab;
Drop Table Tab;
Hi Sunny,
Thanks for you reply. your solution is correct but my requirement is little bit change. Hope you dont mind.
Now I want to sum of all sales for all previous date
For example
if I select 01/05/2015 then Presales would be 1000.
This can be done more easily in front end? Are you looking specifically for a back end solution?
hi soha1902,
you can use the below code for the sum of all the previous days on script.
Tab1:
Load
Date as Date,
Sales as Sales,
RangeSum(Previous(Sales),Peek(Sales,0)) as SumofallPreviousDays
Resident Tab;
Drop Table Tab;
Yes Back End Solution only
Do you know how much back you would be adding? Is it going to be dynamic?
As of now 4 only