Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do I create a script that randomizes Client names? See example.

I want to create a script that creates the normalized column names with non-repetitive numbers that are generated from 1 to the maximum number of clients.

Example:

Client               Normalized
Company A     Client 3

Company B     Client 1

Company C     Client 4

Company D     Client 2

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

If your normalized representation is to be used as a key value, you can use autonumber() to generate consistent numbering across your script, e.g.

   ... autonumber(Client, 'Client') AS Normalized, ...

Peter

View solution in original post

6 Replies
Nicole-Smith

I think you want load script that looks something like this (example also attached):

Data:

LOAD *,

     'Client ' & RecNo() as Normalized

INLINE [

Company, Client

Company A, John Smith

Company B, Jane Smith

Company C, Joe Smith

Company D, Janet Smith

];

DROP FIELD Client;

Peter_Cammaert
Partner - Champion III
Partner - Champion III

If your normalized representation is to be used as a key value, you can use autonumber() to generate consistent numbering across your script, e.g.

   ... autonumber(Client, 'Client') AS Normalized, ...

Peter

Nicole-Smith

Peter Cammaert is right about needing to use autonumber() if Client needs to be a key value.

Something else to think about...  You haven't given us a description on what Clients really are.  If they are people's names, like John Smith, if two different people have the same name, you will end up with the same Client # for them using autonumber, but a different Client # for them using RecNo().

So I think you need to take into consideration if you need Client as a key and what Client really is.

Not applicable
Author

The company names are unique so they can be used as a key. They are large Fortune 500 companies. So for example, a company might be called General Industry. I want to create an anonymized name for that company (I called them the normalized names in my example table), so it could be Client 10. If the list of clients is 30 long. Then I want the normalized list to go from 1 to 30. But I don't want the Client number be in the same order as the alphabet because I don't want someone to guess that client 30 is for example, Zebra Electric.

I hope this explanation helps.

Ed

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Autonumber will number them in the order they are read. If that is not sufficiently random, then you could use autonumberhash128 or autonumberhash256. The hashes should be anonymous. They are not guaranteed to be unique, but with no more than a few hundred names, the chances of a collision are infinitesimal.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thank you all. I ended up using the following. Jonathon was correct that the order of appearance of the clients in the data was random enough.

AutoNumber(CLIENT) as [Client Norm]