Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

autonumber

Hello  evryone what is autonumber ?can anyone explain with example

5 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Its just to create a unique number

From Help Document

autonumber(expression[ , AutoID])

Returns a unique integer value for each distinct evaluated value of expression encountered during the script execution. This function can be used e.g. for creating a compact memory representation of a complex key.

In order to create multiple counter instances if the autonumber function is used on different keys within the script, an optional parameter AutoID can be used for naming each counter.

Examples:

autonumber( Region&Year&Month )

autonumber( Region&Year&Month, 'Ctr1' )

Not applicable
Author

Autonumber will create a number for each unique value of a column.

anbu1984
Master III
Master III

If you are aware of row_number() over(), Autonumber performs the same functionality

Input

ID,ChildID

S1,C2

S1,C1

S1,C4

S1,C3

S2,C2

S2,C5

Output:

select ID,ChildID, row_number() over(partition by ID order by ChildID) from Table

ID,Cktid, SequenceID

S1,C1,1

S1,C2,2

S1,C3,3

S1,C4,4

S2,C2,1

S2,C5,2

Source:

load * inline [

ID,ChildID

S1,C2

S1,C1

S1,C4

S1,C3

S2,C2

S2,C5

];

table:

Load AutoNumber(ChildID, ID) as Sequence,* Resident source

order by ID, ChildID;

DROP Table source;

autonumber(expression[ , AutoID])

Returns a unique integer value for each distinct evaluated value of expression encountered during the script execution. This function can be used e.g. for creating a compact memory representation of a complex key.

In order to create multiple counter instances if the autonumber function is used on different keys within the script, an optional parameter AutoID can be used for naming each counter.

Not applicable
Author

tnks

Anonymous
Not applicable
Author

Hi Praveen,

AutoNumber stores the expression value and gives it a unique integer value. This function can be used e.g. for creating a compact memory representation of a complex key.

Syntax:

AutoNumber (expression [, AutoID])

Example:

LOAD AutoNumber (Product & Region, 'Key') AS KEY_FIELD

If you have two are more common fields between tables,which are  not avoidable .

Then you need to create composite keys between tables, i.e. keys that are concatenations of several other keys. These composite keys are 50 characters long or more and take up a good amount of memory.

So, if you want to save some memory space. The Autonumber() function is used on the composite keys. It replaces long strings with a short number while maintaining all information.



Regards

Neetha