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

Previous value logic

below is the sample data

IDSubIDActual
AB12CDAB12CD100
AB12CDTD123C200
AB12CDPC12KT250
TD123CTD123C300
TD123CPC12KT400
PC12KTPC12KT500
PC12KTKC123T600

when I select step =1, consider below example

for TD123C previos ID is 'AB12CD', now for ID AB12CD there are three value for SubId but I need to pick the subid which is equal to 'TD123C'.. So for TD123C  value should be 200.. So output for step 1 would be


IDValue
AB12CD0
TD123C200
PC12KT400


when step 2 is selected,consider below example


for PC12KT previos to previous ID is 'AB12CD', now for ID AB12CD there are three value for SubId but I need to pick the subid which is equal to 'PC12KT '.. So for PC12KT value should be 250.. So output for step 2 would be


IDValue
AB12CD0
TD123C0
PC12KT250


Note: I need to perform the calculation on front end.


1 Solution

Accepted Solutions
sunny_talwar

Check out the attached

Table:

LOAD *,

  AutoNumber(ID&SubID, 'Key') as Key,

  AutoNumber(ID, 'SNo') as IDSNo,

  AutoNumber(SubID, 'SNo') as SubIDSNo;

LOAD * INLINE [

    ID, SubID, Actual

    AB12CD, AB12CD, 100

    AB12CD, TD123C, 200

    AB12CD, PC12KT, 250

    TD123C, TD123C, 300

    TD123C, PC12KT, 400

    PC12KT, PC12KT, 500

    PC12KT, KC123T, 600

];

Left Join (Table)

LOAD *

Where IDSNo = SubIDSNo;

LOAD IDSNo + IterNo() as IDSNo,

  SubIDSNo,

  Actual as Prev_Actual,

  IterNo() as Step

Resident Table

While IterNo() <= 5;

View solution in original post

1 Reply
sunny_talwar

Check out the attached

Table:

LOAD *,

  AutoNumber(ID&SubID, 'Key') as Key,

  AutoNumber(ID, 'SNo') as IDSNo,

  AutoNumber(SubID, 'SNo') as SubIDSNo;

LOAD * INLINE [

    ID, SubID, Actual

    AB12CD, AB12CD, 100

    AB12CD, TD123C, 200

    AB12CD, PC12KT, 250

    TD123C, TD123C, 300

    TD123C, PC12KT, 400

    PC12KT, PC12KT, 500

    PC12KT, KC123T, 600

];

Left Join (Table)

LOAD *

Where IDSNo = SubIDSNo;

LOAD IDSNo + IterNo() as IDSNo,

  SubIDSNo,

  Actual as Prev_Actual,

  IterNo() as Step

Resident Table

While IterNo() <= 5;