Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a table, I need to show the cumulative sum of the 'Total' column for each products. For example: If i select product 'B' then i should the get the cumulative sum of Product B alone with respective date. i.e 15+2+3=20 not 47+49+52.
I need Output as Below.
Not Like this
May be like this
LOAD Date,
Product,
Quantity,
If(Product = Previous(Product), RangeSum(Peek('Total'), Quantity), Quantity) as Total
Resident ....
Order By Product, Date Asc;
May be like this
LOAD Date,
Product,
Quantity,
If(Product = Previous(Product), RangeSum(Peek('Total'), Quantity), Quantity) as Total
Resident ....
Order By Product, Date Asc;
plz try this
T:LOAD *,Date#(Date,'DD-MM-YYYY') as Date_N INLINE [
Date, Product, Quantity
10-12-2015, A, 1
11-12-2015, A, 2
12-12-2015, A, 3
13-12-2015, A, 4
14-12-2015, B, 3
15-12-2015, B, 5
16-12-2015, B, 6
17-12-2015, C, 10
19-12-2015, C, 12
];
load *, if(rowno()=1, Quantity, if(Product = Previous(Product), RangeSum(Quantity, Peek(Total)),Quantity))as Total
Resident T
order by Product, Date_N asc
;
Do we really need RowNo() = 1 check? Product will not be equal to Previous(Product) which you already gives Quantity, why add the RowNo() condition
Not actually, my bad
Sorry bro
no sorry needed, just fyi
Thanks bro, Got the Answer
Thanks bro
Just one more approach
load Date,
Product,
Quantity,
If(Product = Previous(Product), Peek('Total')+ Quantity, Quantity) as Total
Resident Table
order by Product, Date asc;
Br,
KC
Thanks for the answer bro