Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

anavin33
New Contributor II

Creating a unique ID

I have an ID field in my qlikview document that is considered personal/sensitive data that cannot be shown to other users. I am creating a report that needs to be grouped by this field, so i want to create a secondary ID field, based on the unique values in the original ID field, so that this new ID can be used on the report and sent to users.

Any ideas? I tried autonumber(Orginial ID) and it froze my entire qlikview instance.

1 Solution

Accepted Solutions
MVP
MVP

Re: Creating a unique ID

How much data do you have? Another approach would be to use Peek/Previous to create a unique ID

Table:

LOAD [Original ID],

           ....

FROM ...;

FinalTable:

LOAD *,

           If([Original ID] = Previous([Original ID]), Peek('UniqueID'), RangeSum(Peek('UniqueID'), 1)) as UniqueID

Resident Table

Order By [Original ID];


DROP Table Table;

5 Replies
MVP
MVP

Re: Creating a unique ID

How much data do you have? Another approach would be to use Peek/Previous to create a unique ID

Table:

LOAD [Original ID],

           ....

FROM ...;

FinalTable:

LOAD *,

           If([Original ID] = Previous([Original ID]), Peek('UniqueID'), RangeSum(Peek('UniqueID'), 1)) as UniqueID

Resident Table

Order By [Original ID];


DROP Table Table;

Not applicable

Re: Creating a unique ID

Hi,

If the above does not work... how about using RowNo() when loading the data to give the row a Unique ID...

if needed, you can import the distinct version of your ID with the row number and then use table joins to move the Row Number ID around to other tables in QlikView

JOIN (Data)

LOAD

  *

RESIDENT UniqueIDs;

and then drop the field\tables once finished.

This probably means the Row ID to your UNID changes with every data load

anavin33
New Contributor II

Re: Creating a unique ID

This worked! Thank you so much. One last question, will these IDs change every time we reload the document?

MVP
MVP

Re: Creating a unique ID

They might change based on different the order of [Original ID]

Not applicable

Re: Creating a unique ID

Hi

Directory;

Final:

LOAD Id,

     Amount

FROM

Table;

Final_Data:

LOAD *,

      If([Id]=Previous([Id]),Peek('UniqueID'),RangeSum(Peek('UniqueID'),1)) as UniqueID

      Resident Final

Community Browser