Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Header 1 | Header 2 | Header 3 | Header 4 | Header 5 |
---|---|---|---|---|
product | weeks | data_details | month | sales |
A | 1 | 345 | jan | 234 |
B | 1 | 345 | jan | 343 |
A | 2 | jan | 334 | |
B | 2 | jan | 243 | |
A | 3 | feb | 654 | |
B | 3 | feb | 234 | |
A | 4 | feb | 324 | |
B | 4 | feb | 45 | |
A | 5 | mar | 45 | |
B | 5 | mar | 56 | |
A | 6 | mar | 67 | |
B | 6 | mar | 456 |
i have this table,in which for product A and B we have data_details of 1st week ,
for second week my calculation will be data_details(1st week)-sales(1st week)
for third week my calculation will be data_details(2nd week)-sales(2ndweek)
and same for all next
same will be done if i select product A and week 4 then it should give data_details calculated from 3rd weeks data ?how can i do it ?help me out
Hi,
Try like this
Sample:
LOAD * Inline [
product,weeks,datadetails,month,sales
A, 1, 345,jan, 234
B, 1, 345,jan, 343
A, 2, ,jan, 334
B, 2, ,jan, 243
A, 3, ,feb, 654
B, 3, ,feb, 234
A, 4, ,feb, 324
B, 4, ,feb, 45
A, 5, ,mar, 45
B, 5, ,mar, 56
A, 6, ,mar, 67
B, 6, ,mar, 456
];
NoConcatenate
Sample2:
LOAD
product,
weeks,
if(datadetails='' or isNULL(datadetails),Peek(datadetails)-Peek(sales),datadetails) AS datadetails,
month,
sales;
LOAD *
,RowNo()
Resident Sample
where product='A'
Order by product,weeks;
LOAD
product,
weeks,
if(datadetails='' or datadetails=Null(),Peek(datadetails)-Peek(sales),datadetails) AS datadetails,
month,
sales;
LOAD *,
RowNo()
Resident Sample
where product='B'
Order by product,weeks;
Drop table Sample;