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: 
annanirvin
Contributor III
Contributor III

Create unique ID's

Hi.

I have data as below. I would like to create 73 unique ID with date 2019-04-22, 56 unique ID with date 2019-04-23 etc. The ID for 2019-04-22 must not be the same as for 2019-04-23. How do I do this, please?

DateQty
2019-04-2273
2019-04-2356
2019-04-2464


Thanks 🙂

1 Solution

Accepted Solutions
sunny_talwar

Oh I see, you want the Qty as 1 from the script... do this

Table:
LOAD Date,
	 1 as Qty,
	 Num(Date)*100000+IterNo() as ID
While IterNo() <= Qty;
LOAD * INLINE [
    Date, Qty
    2019-04-22, 73
    2019-04-23, 56
    2019-04-24, 64
];

Hard code the value to be 1, since it will always be 1 and nothing else

View solution in original post

5 Replies
sunny_talwar

Try this

Table:
LOAD Date,
	 Qty,
	 Hash128(Date&IterNo()) as ID
While IterNo() <= Qty;
LOAD * INLINE [
    Date, Qty
    2019-04-22, 73
    2019-04-23, 56
    2019-04-24, 64
];
annanirvin
Contributor III
Contributor III
Author

Hi.

Thanks for your reply. I don't seem to make your suggestion work, I get this very strange IDs. I also forget to tell that I want the quantity to be 1 for each ID, is that possible?

IDQty
MOTH&P=2[:MLHK:PO=>/;&73
MEP54NG.R:M,%=O2*Z,<;&73
M3'<ZNY/U:ML[AH<!&H";&73
M)#)(M#,L:M,,Z%.5!P";&73
sunny_talwar

Do you want to make an ID which makes sense? May be try this

Table:
LOAD Date,
	 Qty,
	 Num(Date)*100000+IterNo() as ID
While IterNo() <= Qty;
LOAD * INLINE [
    Date, Qty
    2019-04-22, 73
    2019-04-23, 56
    2019-04-24, 64
];

For the second question, I am seeing 1 when I use Count(DISTINCT ID) with ID as the dimension

image.png

sunny_talwar

Oh I see, you want the Qty as 1 from the script... do this

Table:
LOAD Date,
	 1 as Qty,
	 Num(Date)*100000+IterNo() as ID
While IterNo() <= Qty;
LOAD * INLINE [
    Date, Qty
    2019-04-22, 73
    2019-04-23, 56
    2019-04-24, 64
];

Hard code the value to be 1, since it will always be 1 and nothing else

annanirvin
Contributor III
Contributor III
Author

This is perfect! Thank you very much.