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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
lmit
Creator II
Creator II

sequence generate

Hi All,

 

I want to have a sequence for one of the column and it should start the sequence from where the last run stopped.

 

for example if 10 was generated by sequence for first run , for second run it should start with 11.

 

I got the first half , to generate the sequence using numeric.sequnce("s1",1,1)

 

can you suggest how can i implement the second part , i went through the forum but couldn't find the solution

 

Thanks in advance,

lmit

Labels (2)
1 Solution

Accepted Solutions
manodwhb
Champion II
Champion II

Thanks @lmit .Please accpect solution.

View solution in original post

11 Replies
Anonymous
Not applicable

Hi  lmit,

 

Please do following steps.

 

1) Create context parameter sequence_max_value.

2) Get Max value of sequence column.

    example : SELECT max(sequence_column) AS sequence_max_value FROM table_name;

    In tJavaRow check if query returns null then assign context.sequence_max_value=1 other                                                           wise context.sequence_max_value=input_row.sequence_max_value(This is max value from table);

3) In the tmap use numeric.sequnce("s1",context.sequence_max_value,1) expression.

 

Note : If you want you can also use ISNULL function in query and assign value 1.

 

 

manodwhb
Champion II
Champion II

in this senario,store your first run max sequnce value in file or Database,before the main you from the input file/database load seq num into context ,and the in tmap,use sequnce funation givet the current value is context value.

lmit
Creator II
Creator II
Author

Hi,

 

Thanks Manohar  & Ravi for your reply.

 

Am not using DB,Its flat file --- so how can i get the max value

 

@ manohar  can i  know how can i store the max value.can you please provide some screenshoots that would be great help.

 

Thanks,

lmit

manodwhb
Champion II
Champion II

you were generating sequence in Var of tmap right,you just pass to one extra optput section and use the tAggregaterow componet to get the Max Values of your sequence.

lmit
Creator II
Creator II
Author

hi Manohar,

I got the value in tAggregaterow  but i got stucked after that how should i produce further

 

Thansk,

limt

manodwhb
Champion II
Champion II

affter tAggregaterow ,use tfileoutputdelimtter and load that value into file.

lmit
Creator II
Creator II
Author

Hi manohar,

 

I stored the value in file.when i want to store the value in the context, should i store in local or global variable , if so then how.

 

Thanks,

lmit

manodwhb
Champion II
Champion II

read the same file and loaded into context using tContextload in the main flow of same job,where you are generating the sequence in tmap

lmit
Creator II
Creator II
Author

Thanks Manohar , will try this option.

 

Thanks once again 0683p000009MACn.png

 

Thanks,

lmit