Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Sequence not starting from previous value

Hi,

I'm trying to generate the sequence number for each newly inserted value. But when i'm inserting new records and run the job again, the sequence starts from 1 for the new values but not from the previous (max) value.

This is the expression i have used  "Numeric.sequence("s2",(row5.id == null?1:row5.id)+1,1)  ", where row5.id is the max id from aggregaterow component.

Please find the attached screenshot for reference.

 

Thanks

 

Labels (2)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

Try to get the current max value in a 1st subjob (reuse what you do tFileInputExcel_3 and tAggregateRow_1).

Push the result into a global variable ("curMax" in the following).

Connect the new subjob to tFileInputExcel_1 using a "On Subjob Ok" triger. 

Remove the tMap input associated to row5.

In tMap_1, set the out1 id with the following

Numeric.sequence("s2", (Integer)globalMap.get("curMax", 1))

Hope this helps.

View solution in original post

10 Replies
TRF
Champion II
Champion II

Hi,

Can you share your tMap?

Anonymous
Not applicable
Author

Hi TRF,

 

Please find the attached screenshot of tMap.

 

Thanks


Capture.JPG
TRF
Champion II
Champion II

Try to get the current max value in a 1st subjob (reuse what you do tFileInputExcel_3 and tAggregateRow_1).

Push the result into a global variable ("curMax" in the following).

Connect the new subjob to tFileInputExcel_1 using a "On Subjob Ok" triger. 

Remove the tMap input associated to row5.

In tMap_1, set the out1 id with the following

Numeric.sequence("s2", (Integer)globalMap.get("curMax", 1))

Hope this helps.

Anonymous
Not applicable
Author

Thanks TRF !

It worked like a charm. Attaching the screenshot for others reference.

 

And TRF, Can you please explain what is wrong with the first version of the Job. I reckon the value of tAggregate component is not propagated correctly, isn't it ?


2.JPG
Anonymous
Not applicable
Author

Push the result into a global variable ("curMax" in the following).

 

How do you push the result into a global variable?

 

which component and syntax to be used?

TRF
Champion II
Champion II

Great!

Need to know what in the component to try to explain why it doesn't work as desired.

Share details if needed.

Anonymous
Not applicable
Author

As per your reply in the one of the post you have metioned this.

 

I am also trying to understand where do you implement this step.

 

Attached is the post that i am talking about.


capture.PNG
TRF
Champion II
Champion II

OK.

You need to use globalMap.put method for that.

Based on the previous post, it should look like this (I assume the field containing the value to store into the global variable is called maxValue):

globalMap.put("curMax", row5.maxValue);
Anonymous
Not applicable
Author

Can you please check the attached screenshot and let me know if it is correctly done?

 

If it is correctly done, then also i am not able to set up the max value to the variable instead it is coming as 0.

 

Output: the max value is :0

 

Thanks in advance!

 

 


capture_2.PNG