Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello!
I have pivot table like this
| Store | Month | Week | Sales | Sum Sales |
|---|---|---|---|---|
| Store1 | 1 | 1 | 5 | 5 |
| Store1 | 2 | 5 | 7 | 12 |
| Store1 | 2 | 6 | 11 | 23 |
| Store2 | 2 | 7 | 10 | 10 |
| Store2 | 2 | 8 | 6 | 16 |
| Store2 | 3 | 9 | 9 | 25 |
I need Sum Sales column to show growing Sales during the store
I need Sum Sales column to show growing Sales during the store??? Not sure what you mean? Can you please clarify.
Best,
Sunny
Sorry If I'm not clear enough . Look for Store1, first week sales = 5, 5 week sales = 5(prev week) + 7(current week) = 13, 6 week sales = 13(prev week) + 11(current week) and so on
Try this,
Data:
LOAD * INLINE [
STORE, MONTH, WEEK, SALES
Store1, 1, 1, 5
Store1, 2, 5, 7
Store1, 2, 6, 11
Store2, 2, 7, 10
Store2, 2, 8, 6
Store2, 3, 9, 9
];
Data2:
NoConcatenate
Load
STORE,
MONTH,
WEEK,
SALES,
if(STORE=peek(STORE),SALES+Peek(CUMU_SALES),SALES) as CUMU_SALES
resident Data
order by STORE asc, MONTH asc, WEEK asc
;
drop table Data;
it should be done in pivot table, according to different filters
use range sum with above
rangesum(above(sum(Sales), 0 , RowNo())))