Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I would like to create a cumulative values of [Adunt Impacts] using the following script:
RangeSum([Adult Impacts],Peek('Cumulative_AdsImpact')) as Cumulative_AdsImpact
However to make sense of it my date need to be sorted by DateTime field before cumulation.
How can I sort my data in script?
Any ideas pleae?
Thanks
Like this:
ConsData:
Load
Date,
[Adult Impacts],
....
ResultData:
NoConcatenate LOAD
Date,
[Adult Impacts],
RangeSum([Adult Impacts],Peek([Cumulative Adult Impacts])) as [Cumulative Adult Impacts],
...
Resident ConsData Order By Date;
Drop table ConsData; // ConsData is no longer needed, all the data is now in table ResultData
Use the following example script
Data:
LOAD * Inline [
Date, Adult Impacts
1/2/2013,10
1/4/2013,20
1/3/2013,25
1/1/2013,5
];
Result:
NoConcatenate LOAD Date, [Adult Impacts]
,RangeSum([Adult Impacts],Peek([Cumulative Adult Impacts])) as [Cumulative Adult Impacts]
Resident Data Order By Date;
Sample application is attached.
Does it mean I have to manually write all Dates and Impacts?
No. If you have your data in a table named 'Data', you may use it in the second load.
For the sample application to illustrate the script, I loaded data as Inline load.
I have this table ConsData with data loaded already:
ConsData:
Load
Date,
[Adult Impacts],
...
So below that I need to type your code?
NoConcatenate LOAD Date, [Adult Impacts]
,RangeSum([Adult Impacts],Peek([Cumulative Adult Impacts])) as [Cumulative Adult Impacts]
Resident Data Order By Date;
Sorry but I am quiet new to it.
Like this:
ConsData:
Load
Date,
[Adult Impacts],
....
ResultData:
NoConcatenate LOAD
Date,
[Adult Impacts],
RangeSum([Adult Impacts],Peek([Cumulative Adult Impacts])) as [Cumulative Adult Impacts],
...
Resident ConsData Order By Date;
Drop table ConsData; // ConsData is no longer needed, all the data is now in table ResultData
Thanks Gysbert for detailed explenation. It was really helpful to get the idea.