Assigning Column value from previous row column value

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Lotus26
Premium Member
Premium Member
Posts: 48
Joined: Tue Jul 13, 2004 2:09 pm

Assigning Column value from previous row column value

Post by Lotus26 »

Hi All,


I struck up doing a job here. I have a data file in the following format.

LOC DEPT STOCK
10, 1, 10
, 2, 20
, 3, 15
, 4, 15
20, 5, 10
, 8, 15
, 12, 12
30, 25, 15
, 30, 15



I have to assign the LOC '10' to the 2nd,3rd,4th records and LOC '20' to the next two records and 30 to the next record. Can any one help me in doing this job.

The ouput of the job should be

LOC DEPT STOCK
10, 1, 10
10, 2, 20
10, 3, 15
10, 4, 15
20, 5, 10
20, 8, 15
20, 12, 12
30, 25, 15
30, 30, 15



I appreciate your time and help in advance

Thanks
Lotus
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

Use transformer stage:
define a stage varialbles

Sprev=(If LOC='' Then LOC Else Sprev)

and map this variable to the LOC Column
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

sorry the varibale value shoukd be

Sprev=(If LOC<>'' Then LOC Else Sprev)
Lotus26
Premium Member
Premium Member
Posts: 48
Joined: Tue Jul 13, 2004 2:09 pm

Post by Lotus26 »

I figured it out. Thanks for your time
keshav0307 wrote:sorry the varibale value shoukd be

Sprev=(If LOC<>'' Then LOC Else Sprev)
Regards
Lotus26
boppanakrishna
Participant
Posts: 106
Joined: Thu Jul 27, 2006 10:05 pm
Location: Mumbai

try this ,this may be helpful

Post by boppanakrishna »

Lotus26 wrote:I figured it out. Thanks for your time
keshav0307 wrote:sorry the varibale value shoukd be

Sprev=(If LOC<>'' Then LOC Else Sprev)

Hi all,
For this example take "lpre" and for the "lpre" variable assign the logic as " If Inputlink.Loc = " " Then lpre Else DSLink3.Loc "
In the out put derivation,assign "lpre" variable to the "LOC" column
Post Reply