how to get last value in each row

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
jhansi
Participant
Posts: 33
Joined: Sat May 26, 2012 4:56 am

how to get last value in each row

Post by jhansi »

source
a
a_b
a_b_c
a_b_c_d

target
a
b
c
d
jhansi
chetan.c
Participant
Posts: 112
Joined: Tue Jan 17, 2012 2:09 am
Location: Bangalore

Post by chetan.c »

Hi,

In the output derivation:

Code: Select all

field(DSLink2.val,"_", @INROWNUM)
Transformer has to run in sequential mode.


Thanks,
Chetan.C
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I seriously doubt that example actually represents the incoming data such that you can assume the last field will always match the row number. A generic answer would be to count() the delimiters and pull the "count+1" field from the "_" delimited string.
-craig

"You can never have too many knives" -- Logan Nine Fingers
trammohan
Participant
Posts: 47
Joined: Thu Nov 13, 2003 12:47 pm

Post by trammohan »

DSLink8.val[ Len(Trim(DSLink8.val )),1]
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

trammohan wrote:DSLink8.val[ Len(Trim(DSLink8.val )),1]
Again, I think people are putting too much faith in the accuracy of the example posted. They want the last "value" / field, not the last character.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Field(InLink.TheString, delimiter, Count(InLink.TheString, delimiter) + 1, 1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Field(InLink.TheString, delimiter, Count(InLink.TheString, delimiter) + 1, 1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just like I said. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply