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: 
kailashkotak91
Contributor III
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
Specialist
Specialist

Hi,

Maybe something like this:

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

I hope this is helpful,

Cheers,

L

View solution in original post

9 Replies
kailashkotak91
Contributor III
Contributor III
Author

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
Specialist
Specialist

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
Partner - Master III
Partner - Master III

provide some sample data to generalize expression

vinieme12
Champion III
Champion III

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 '_'

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

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

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
kailashkotak91
Contributor III
Contributor III
Author

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

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

purgechar(key, '_')

-Rob

michael_solomon
Partner - Contributor III
Partner - Contributor III

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
Contributor III
Contributor III
Author

Thank you everyone!