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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
JL1996
Contributor III
Contributor III

Need Unique ID from 3 different fields in single expression - Qlik Sense

Dear all Qlik experts, 

I am new to QlikSense and I am trying to create a unique ID for unique records in a new column or simply output the unique record under certain conditions 

for records with same date and same brand name under the same QR Code will be only counted as one in new column - E

Sample: 

123.PNG

thanks for helping once again! 

 

 

 

10 Replies
MayilVahanan

Hi @JL1996 

Try like below

Load *,
If(Previous(QRCode&'|'&BrandName&'|'&DateOfDelivery)<>
(QRCode&'|'&BrandName&'|'&DateOfDelivery),1,0) as UniqueID
resident yourdatasource
order by QRCode, BrandName, DateofDelivery;

Drop table yourdatasource;

Hope it helps;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
JL1996
Contributor III
Contributor III
Author

hello there, 

I am now using Qlik Sense which I dont think it will be applicable to QlikSense? This is suppose to be a little bit different from QlikView? thanks

MayilVahanan

Hi @JL1996 

Try like below

T:
Load * Inline
[
QRCode,BrandName,Department,DateOfDelivery
AAA,Coca-Cola,Department A,2-Jan-20
AAA,Coca-Cola,Department A,2-Jan-20
AAA,Coca-Cola,Department A,2-Jan-20
AAA,Coca-Cola,Department A,2-Jan-20
AAA,Coca-Cola,Department A,3-Jan-20
BBB,Coca-Cola,Department A,5-Jan-20
CCC,Coca-Cola,Department A,8-Jan-20
AAA,Pepsi,Department G,9-Jan-20
AAA,Pepsi,Department G,10-Jan-20
AAA,Pepsi,Department G,11-Jan-20
AAA,Juice,Department G,12-Jan-20
AAA,Choco,Department G,13-Jan-20
];

Load *, if(Previous(QRCode&'|'&BrandName&'|'&Department)<>(QRCode&'|'&BrandName&'|'&Department), 1,0) as UniqueID
Resident T Order by QRCode, BrandName, Department, DateOfDelivery;

Drop Table T;

Output:

MayilVahanan_0-1606459473414.png

 

Please change inline table with ur source. And please try to provide sample excel sheet / table instead of image.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
JL1996
Contributor III
Contributor III
Author

hello there, really appreciate for your help but can you kindly teach me how to do it in QlikSense? I dont see a "upload script button" in Qlik Sense. thanks

MayilVahanan

Hi @JL1996 

MayilVahanan_0-1606461918783.png

 

If you are not able to see the highlighted option, Please check with Qlik Admin for your access.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
JL1996
Contributor III
Contributor III
Author

thanks i am now able to find it, but there are two options which is "Main" & "Auto-generated section". Which one should I insert the script there? thanks

MayilVahanan

Hi @JL1996 

Without see ur file, am not able to suggest. Could you please refer below link about data load editor.

https://www.youtube.com/watch?v=Pl9QKCifUTg&list=PLXwuEW0xHpwwc7ZWGQh_0ePEligqDp2hu&index=7

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
JL1996
Contributor III
Contributor III
Author

hello there,

Please take a look at the sample file if you have time please. 

btw is there an easier way to create the unique ID? lets say can we possibly use some formulas instead of typing the entire script while loading? thanks!

ArnadoSandoval
Specialist II
Specialist II

Hi @JL1996 

I have some issues understanding your definition of unique id, as the records on row 2, 7, 8, 9, 12 and 13 have a Unique ID of 1, so the Unique ID is not that unique (that is my interpretation)

I will say the Unique ID of your records is this expression:

[QR Code] & '|' & [Brand Name] & '|' [Department]

 Now, if you use the AutoNumber() function, you get an integer as Unique ID, like this:

AutoNumber([QR Code] & '|' & [Brand Name] & '|' [Department])

Now, it will be good to know what to do with those records having a "duplicated" Unique ID?

Hope this helps,

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.