Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
IT-Vivo_group
Contributor
Contributor

How to make conditionnal increment

hello,

I'm looking to increment a field based on another field in a TMAP with

I would like to increment each line having the same value in the second field.

I think you have to use the command Numeric.resetSequence("s1",1) but I don't know how to insert the condition

In the input file, i have

AAA

AAA

AAA

BBB

BBB

BBB

And the expected result

AAA 1

AAA 2

AAA 3

BBB 1

BBB 2

BBB 3

Thank you for your feedback

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hello,

If you want to use one sequence for each product(AAA, BBB,CCC)

For example, if your main input is row1 and the input first field is product

Numeric.sequence(row1.product,1,1).

Hope it helps.

Best regards

Sabrina

View solution in original post

5 Replies
gjeremy1617088143
Creator III
Creator III

Hi @Service IT Vivo group​ , you just have to put Numeric.Sequence("S1",1,1) in an output field of data type int of a tMap,

you just have to remind that when you create a sequence and you want to use it in another part of the job it won't be reset and continue to increment, you have to reset it first. If you just want to use it in one part of the job you just have to use Numeric.Sequence("S1",1,1) , with "S1" the name of the sequence, 1 the start value and another 1 the increment value.

Send me love and kudos.

IT-Vivo_group
Contributor
Contributor
Author

Hi,

 

Thanks, but that doesn't solve my problem.

With Numeric.Sequence("S1",1,1)

I end up at the output with a file

AAA 1

AAA 2

AAA 3

BBB 4

BBB 5

BBB 6

 

I want the increment to reset automatically when the first field changes (AAA becomes BBB then CCC...)

 

AAA 1

AAA 2

AAA 3

BBB 1

BBB 2

BBB 3

CCC 1....

Anonymous
Not applicable

Hello,

If you want to use one sequence for each product(AAA, BBB,CCC)

For example, if your main input is row1 and the input first field is product

Numeric.sequence(row1.product,1,1).

Hope it helps.

Best regards

Sabrina

IT-Vivo_group
Contributor
Contributor
Author

Hello,

 

this is exactly that i want.

Thank you!

Anonymous
Not applicable

Hello,

Great it helps. Feel free to let us know if there is any further help we can give.

Best regards

Sabrina