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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
jblomqvist
Specialist
Specialist

How Can I restart my AutoNumber process after every new Company Code in the script?

Hello,

I have some data that looks like the following:

CompanyCode
YearMonthAutoNumberNEW AutoNumber
A2015-0111
A2015-0222
A2015-0333
B2015-0141
B2015-0252
C2014-1061
C2014-1172

My current AutoNumber expression in the script looks like:

AutoNumber(CompanyCode & '-' & YearMonth)

But it gives me a continues numbering like you see in the AutoNumber column example.

What I want to do is get my AutoNumber output to be like NEW AutoNumber column where it restarts after a new CompanyCode even if YearMonth values are similar.

Does anyone know how to do this please?

1 Solution

Accepted Solutions
maxgro
MVP
MVP

AutoNumber(CompanyCode & '-' & YearMonth, CompanyCode)

View solution in original post

8 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Just a minor remark: is the [NEW AutoNumber] value for the first CompanyCode=B row correct?

jblomqvist
Specialist
Specialist
Author

Thank you for pointing that out! I have corrected the example

maxgro
MVP
MVP

AutoNumber(CompanyCode & '-' & YearMonth, CompanyCode)

MarcoWedel

AutoNumber(YearMonth, CompanyCode)

Peter_Cammaert
Partner - Champion III
Partner - Champion III

If you just want to restart the counter in your load script, see this discussion and the example document: Numbering Rows more examples? One of the three methods fits your bill

Peter.

jblomqvist
Specialist
Specialist
Author

Thank you so much Massimo you are a star!

jblomqvist
Specialist
Specialist
Author

Thank you Marco for your reply

maxgro
MVP
MVP

Marco's answer is better than mine