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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

best way to scramble/anonymise particular fields in script

Hi, im looking for te best way to scramble/anonymise a particular field in the load script.

I have seen the Scramble feature in the document properties but this is no good as it has to be performed after each reload.  Also heard about the hash128() feature, but this returns a string that is too long.

Im currently using an autonumber feature (see my script below):

IF (match(costcentre_lcode, 'HRAB','HRAF','HRAR','HRAQ','NAAQ','HRAC','HRAA'),'PRIVATEPatient_'&autonumber(patientID),patientID) as patientID

What this script is doing is finding all the patients that belowing to particular costcentres if any are found then the paitentID is prefixed with ''PRIVATEPatient_"& an autonumber.  Otherwise the PatientID is kept the same.

example of output PatientID

567654657898

PRIVATEPatient_1

PRIVATEPatient_2

PRIVATEPatient_3

Is there a way to create a random patientID (kept to maximum 10 characters) rather then sequential numbers????

2 Replies
erichshiino
Partner - Master
Partner - Master

Hi,

You can use the following script to generate a number of unique random numbers (with regular format)

hope this helps,

Erich

tRAND:

LOAD TEXT ( NUM( ROUND(RAND()*10000000000), '00000000000')) AS tempID

AutoGenerate(10000); // you can control how many itens will be generated.

//Your result may have less then this, since you can have some duplicated.

RAND:

//duplicated numbers will be excluded

//random number will be formated as text to have the same number os characters

//AUTONUMBER will be an index to this table (you may not need it)

LOAD DISTINCT tempID AS ID, ROWNO() AS AUTONUMBER

RESIDENT tRAND

// WHERE ROWNO()<5000 //hre you can control how many itens you want to keep

;

drop table RAND;

Not applicable
Author

I am in healthcare and we do it a few different ways, though nothing complex. It all depends on how secure you want the info to be.

If the user does not need the patient ID, we simply do not show it.  In that case there is no need to obfuscate the actual number.  That might look like this:

IF (match(costcentre_lcode, 'HRAB','HRAF','HRAR','HRAQ','NAAQ','HRAC','HRAA'),'PRIVATEPatient',patientID) as patientID

If we are trying to scramble the data, for a demonstration perhaps, and the data needs to "look" real.

IF (match(costcentre_lcode, 'HRAB','HRAF','HRAR','HRAQ','NAAQ','HRAC','HRAA'),'PRIVATEPatient' & left(patientID * 9, 10),patientID) as patientID