Compare row then increase

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
kayarsenal
Participant
Posts: 17
Joined: Mon Jan 16, 2006 2:11 pm
Contact:

Compare row then increase

Post by kayarsenal »

Hi,
Please how will I solve such a scenario?

I have a column A:


23434
45235
AB234
13443
12444
AB324
13443
AB324
12334

I want such an output

23434 1
45235 2
AB234 3
13443 3
AB324 4
13443 4
AB324 5
12334 5

Basically if column A[1,2]="AB" the number remains the same. I defined sth like this in stage var:

If Prev <> "AB" AND yyy.A[1,2] = "AB" Then xxx Else xxx +1 xxx(stage var 1)

yyy.A Prev(stage var 2)

This gives an output like this:

23434 1
45235 2
AB234 2
13443 3
AB324 3
13443 4
AB324 4
12334 5

Rgds,
K
ARSENAL GUNNERS GOONER
kayarsenal
Participant
Posts: 17
Joined: Mon Jan 16, 2006 2:11 pm
Contact:

follow up

Post by kayarsenal »

Thank you.Its already working. I noticed my mistake
ARSENAL GUNNERS GOONER
ag_ram
Premium Member
Premium Member
Posts: 524
Joined: Wed Feb 28, 2007 3:51 am

Re: Compare row then increase

Post by ag_ram »

kayarsenal wrote:Hi,
Please how will I solve such a scenario?

I have a column A:


23434
45235
AB234
13443
12444
AB324
13443
AB324
12334

I want such an output

23434 1
45235 2
AB234 3
13443 3
AB324 4
13443 4
AB324 5
12334 5

Basically if column A[1,2]="AB" the number remains the same. I defined sth like this in stage var:

If Prev <> "AB" AND yyy.A[1,2] = "AB" Then xxx Else xxx +1 xxx(stage var 1)

yyy.A Prev(stage var 2)

This gives an output like this:

23434 1
45235 2
AB234 2
13443 3
AB324 3
13443 4
AB324 4
12334 5

Rgds,
K

U can use 2 sort stages , the first one will sort , the second one will produce a KeyChange . Then have a transformer , that looks for the key change field . Keep incrementing till then .it should work
ganesh123
Participant
Posts: 70
Joined: Tue Feb 20, 2007 3:22 pm
Location: NJ,USA
Contact:

Post by ganesh123 »

Please mark the topic RESOLVED
If women didn't exist, all the money in the world would have no meaning.
-- Aristotle Onassis
Post Reply