Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create an unique key for duplicate Values

Hi,

I trying to create unique number for repeting vaules in script level

Eq

ValueTrying to create Key
11
12
13
14
21
23
24
31
32

Can any one help

regards

Mahesh

1 Solution

Accepted Solutions
rbecher
MVP
MVP

Hi Mahesh,

this works:

Data:

LOAD * INLINE [

    Value

    1

    1

    1

    1

    2

    2

    2

    3

    3

];

Result:

NOCONCATENATE LOAD Value, if(IsNull(Previous(Value)) or Value>Previous(Value), 1, Peek(Key)+1) as Key

Resident Data;

- Ralf

Vizlib Head of R&D

View solution in original post

5 Replies
rbecher
MVP
MVP

Hi Mahesh,

this works:

Data:

LOAD * INLINE [

    Value

    1

    1

    1

    1

    2

    2

    2

    3

    3

];

Result:

NOCONCATENATE LOAD Value, if(IsNull(Previous(Value)) or Value>Previous(Value), 1, Peek(Key)+1) as Key

Resident Data;

- Ralf

Vizlib Head of R&D

View solution in original post

Gysbert_Wassenaar

Try:

Data:

LOAD *, if(Value=previous(Value), peek(Key)+1,1) as Key INLINE [

    Value

    1

    1

    1

    1

    2

    2

    2

    3

    3

];


talk is cheap, supply exceeds demand
swuehl
MVP
MVP

Another option:

Data:

LOAD *, autonumber(recno(),Value) as Key INLINE [

    Value

    1

    1

    1

    1

    2

    2

    2

    3

    3

];

er_mohit
Master II
Master II

Try this

Data:

LOAD * INLINE [

    Value

    1

    1

    1

    1

    2

    2

    2

    3

    3

];

NewData:

LOAD Value,

if(Previous(Value)<>Value,1,RangeSum(1,Peek(Key))) as Key

Resident Data

Order by Value;

DROP Table Data;

output like this

ValueKey
11
12
13
14
21
22
23
31
32

See the attached file

rbecher
MVP
MVP

Interesting solution! But, this could be expensive for QV to handle a large amount of counters..

- Ralf

Vizlib Head of R&D