Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
kailashkotak91
New Contributor III

Replace function to insert "_" in data

Hello,

In my column (Unique identifier) I have data in this format 111122223333. I want to have data as 1111_2222_3333 format. This column has more that 150k records. How can i replace data from this format 111122223333 to 1111_2222_3333.

Can I do this in my load script when i load the unique identifier column? Thank you in advance!

Regards,

Kailash

1 Solution

Accepted Solutions
luismadriz
Valued Contributor

Re: Replace function to insert "_" in data

Hi,

Maybe something like this:

Left(Field,4)&'_'&Mid(Field,5,4)&'_'&Right(Field,4) as FormattedField?

I hope this is helpful,

Cheers,

L

9 Replies
kailashkotak91
New Contributor III

Re: Replace function to insert "_" in data

I need it in this format because i have to join this column with other table where the unique identifier is in 1111_2222_3333 format

luismadriz
Valued Contributor

Re: Replace function to insert "_" in data

Hi,

Maybe something like this:

Left(Field,4)&'_'&Mid(Field,5,4)&'_'&Right(Field,4) as FormattedField?

I hope this is helpful,

Cheers,

L

shraddha_g
Honored Contributor III

Re: Replace function to insert "_" in data

provide some sample data to generalize expression

vinieme12
Esteemed Contributor II

Re: Replace function to insert "_" in data

then why don't you replace the '_' with '' in the key of your other tables?  that is relatively simpler!

so all your keys are in 111122223333 format without the '_'

vinieme12
Esteemed Contributor II

Re: Replace function to insert "_" in data

also if you already have well formatted keys in other tables then you can also create a mapping table by replacing the '_' with null

kailashkotak91
New Contributor III

Re: Replace function to insert "_" in data

Hi Vineet,

Thanks for the suggestion. Can you give me an example. I can change the format of either of the table. Can you give me an example for it ?

Regards,

Kailash Kotak

MVP & Luminary
MVP & Luminary

Re: Replace function to insert "_" in data

purgechar(key, '_')

-Rob

michael_solomon
New Contributor III

Re: Replace function to insert "_" in data

I would be careful about removing the '_' as it is a character delimiter that can make all the difference as a unique identifier. If your field is always formatted the same way, Eg 12 characters long, then removing the '_' can work. However if the format is not structured, then removing the '_' may also remove the uniqueness. For example 1_23 and 12_3 would both be represented as 123 if you removed the '_', and therefore you can no longer use that field to distinguish between 1_23 and 12_3.

kailashkotak91
New Contributor III

Re: Replace function to insert "_" in data

Thank you everyone!