Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to calculate data from table,where input of one data will be output for next

Header 1Header 2Header 3Header 4Header 5
productweeksdata_detailsmonthsales
A1345jan234
B1345jan343
A2jan334
B2jan243
A3feb654
B3feb234
A4feb324
B4feb45
A5mar45
B5mar56
A6mar67
B6mar456

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

HIDE FULL PREVIEW

1 Reply
Not applicable
Author

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;