Generate the Occurrence Number in Output File

How to generate the occurrence no in out put file for the respective no of records in input file
I need a count in the target file how many times the same record is available in input file.
INPUT
-----
ID NAME LOC
20 B Y
10 A X
20 B Y
30 C Z
10 A X
10 A X
20 B Y
20 B Y
30 C Z
OUTPUT I NEED
-----------------------
ID NAME LOC OCCURENCE
10 A X 3
20 B Y 4
30 C Z 2
Please help me how to develop a job to get the respective output

Questions by Aloka   answers by Aloka

Showing Answers 1 - 9 of 9 Answers

Vishnu

  • Jul 19th, 2016
 

We can achieve this with using aggregate stage with ID, Name, LOC as Keys/Group and creating a new column for Count.

  Was this answer useful?  Yes

Sri

  • Jul 20th, 2016
 

First sort the incoming rows by ID, NAME and LOC.
Then take three stage variables in the transformer

StageVar=inputcol
StageVar1=Stagevar
StageVar2=if StageVar=StageVar1 then StageVar2+1 else 1
map the StageVar2 to the output link column

  Was this answer useful?  Yes

Thanks Sri for your reply.
After using 3 stage variable in xfm we can generate the count of the respective record.But after that i need no remove the duplicates to get the unique respective record in target.If I will use RD stage after xfm can i get the count in my out put file.
If you will explain it in step by step it will be more helpful.
Thanks !
Aloka

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions