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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

splitting a string during load

Hi all,

In the db/app I am building we have paid for an external mapping of string terms to a variety of "categories". The results have been returned to me in a table like this:

Key FieldCategories
a string[cat1,cat2]
another string[cat2,cat3,cat4]
yet another string[cat2, cat4]
other string[cat1, cat5]
further string[cat2, cat4]

The categories field rows are strings surrounded by square brackets and delimeted by ",".

I want to load the data so that I end up with a table like this:

Key FieldCategories
a stringcat1
a stringcat2
another stringcat2
another stringcat3
another stringcat4
yet another stringcat2
yet another stringcat4
other stringcat1
other stringcat5
further stringcat2
further stringcat4

So that I am able to look at all the Key field strings associated with a certain category.

e.g in this case cat1 would be associated with "a string" and "other string"

Can you give me some pointers on how to achieve this?

Many thanks

Mark

2 Replies
Anonymous
Not applicable
Author

Hi Mark,

You can use the SubField() function in the script.

Subfield(Categories,',') as Categories

You might want to strip out the [ and ] as well if they are there in the data.. use Subfield(Purgechar(Categories,'[]'),',') as Categories in that case

Not applicable
Author

Hi Johannes,

Thanks,

you know I had already tried the substring() function, and had not got it to work, but follwoing your reply, I employed it then realised that I had made an error in my script and not got the key field correct!

I correct that error and the data loaded great first time.

Thanks for your help

Mark