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: 
Not applicable

Load as X if field contains Y

Hello!

I would like to load data from the field [Category] that contains values that I want to break out into separate fields e.g.:

Name_[Type]_[Segment]

John_Blue_Big

Anna_Green_Small

George_Blue_Small

How should the script be written to load the values as 3 separate fields (Name, Type, Segment)?

Thank you!

3 Replies
simonc-cfn
Contributor III
Contributor III

Hi Jason,

For your requirement and example... consider the following...

I created an inline table with the following...

Table:

load * inline [

Field1

Name_Type_Segment

]

;

To break out each value into its own field, you can use the following...

Table2:

load

SubField(Field1,'_',1) as Name,

SubField(Field1,'_',2) as Type,

SubField(Field1,'_',-1) as Segment

resident Table

;

Hope this helps.

Simon

sujeetsingh
Master III
Master III

You can use subfield with different arguments.

subfield(Field,'_',1) as Column1

subfield(Field,'_',2) as Column2


subfield(Field,'_',3) as Column3