Numeric sequence based on certain data

Six Stars

Numeric sequence based on certain data

Hello.
I want to generate numeric sequence based on column data
for example:

Column: Invoice_Num|GUID
123|sajkshd87a(...)
123|dmcnz,nc(...)
123|cnxcnx(...)
124|sdsjkdhsjk(..)
124|mcnxm,cnx,mn(...)
The expectec output is
Column: Invoice_Num|GUID|numeric
123|sajkshd87a(...)|1
123|dmcnz,nc(...)|1
123|cnxcnx(...)|1
124|sdsjkdhsjk(..)|2
124|mcnxm,cnx,mn(...)|2
The increment of the sequence depends on invoice column
I search the forum, but no lucky.
Thanks
Moderator

Re: Numeric sequence based on certain data

Hi,
Use below expression in tMap Var section:
Numeric.sequence(row1.Invoice_Num,1,1)

.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Highlighted
Six Stars

Re: Numeric sequence based on certain data

Hi Sabrina.
Thanks for your quick reply.
Your solution was the solution that I was trying and now it is working because db type now is int. Was a string before.
My mistake.
Now I have other issue.
I have to make 2 sequences in two separate columns.
I kown that tmap has a function numeric.resetsequence, but how do I apply it?

Thanks
Moderator

Re: Numeric sequence based on certain data

Hi,
I have to make 2 sequences in two separate columns.

Could you please elaborate your case with an example with input and expected output values?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Six Stars

Re: Numeric sequence based on certain data

Hi Sabrina:
Right now output is:
-1|37115|-1|FAC-36012013|241.87|
-2|37115|-2|FAC-36012013|196.64|
-3|37115|-3|FAC-36012013|196.64|
-4|37115|-4|FAC-36012013|0.00|
-5|37115|-5|FAC-36012013|0.00|
-6|37115|-6|FAC-36022013|171.72|
-7|37115|-7|FAC-36022013|139.61|
-8|37115|-8|FAC-36022013|139.61|
-9|37115|-9|FAC-36022013|0.00|
-10|37115|-10|FAC-36022013|0.00|
-11|37115|-11|FAC-36032013|124.25|
-12|37115|-12|FAC-36032013|96.27|
-13|37115|-13|FAC-36032013|96.27|
-14|37115|-14|FAC-36032013|4.75|
-15|37115|-15|FAC-36032013|4.75|

1st numeric sequences is based on string: "FAC-36012013"
2nd numeric sequences is based on sub-string: "36012013" (a Fake column) because if I based the numeric sequence on the same row the result will be:
Column 1: 1,3,5,7,9 and so on...and 2nd column will be:2,4,6,8,10 and so on..

Desired output:
-1|37115|-1|FAC-36012013|241.87|
-1|37115|-1|FAC-36012013|196.64|
-1|37115|-1|FAC-36012013|196.64|
-1|37115|-1|FAC-36012013|0.00|
-1|37115|-1|FAC-36012013|0.00|
-2|37115|-2|FAC-36022013|171.72|
-2|37115|-2|FAC-36022013|139.61|
-2|37115|-2|FAC-36022013|139.61|
-2|37115|-2|FAC-36022013|0.00|
-2|37115|-2|FAC-36022013|0.00|
-3|37115|-3|FAC-36032013|124.25|
-3|37115|-3|FAC-36032013|96.27|
-3|37115|-3|FAC-36032013|96.27|
-3|37115|-3|FAC-36032013|4.75|
-3|37115|-3|FAC-36032013|4.75|

Thanks again
Six Stars

Re: Numeric sequence based on certain data

Hello!
Can anyone help with this issue?
Thanks

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog