Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
joey_lutes
Partner - Creator
Partner - Creator

Using subfield with multiple selections

I'm trying to do what I think might be a simple thing, though I might be going at it wrong.

I have a piece of data (which happens to be a filename, but not too important)

it's in format:

Word-Thing-Idea-Number-Description-Iteration

What I want is to parse out the first 4 subfields and call that 'id', ending up with:

Word-Thing-Idea-Number  only.

The lengths are different, so left() won't work.

subfield() seems to be producing strange results when I try different things.

Any way besides splitting it out individually and then re-concatenating it?

thanks in advance.

1 Solution

Accepted Solutions
vishsaggi
Champion III
Champion III

May be try this?

LOAD *, LEFT(data, Index(data, '-',4)-1) AS NewDatafield INLINE [

id, data

1, ab-cde-efgh-ij-k-lm 

2, abc-de-fg-hij-klm

];

View solution in original post

4 Replies
Anil_Babu_Samineni

That means, You are going to get first 4 words from Field?

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Siva_Sankar
Master II
Master II

Hi Joey,

Subfield should work. Can you post or upload an example or your requirement in a qvw file?

Some examples for you How to Split the string into number of sub strings and how to extract date from filename

-Siva

joey_lutes
Partner - Creator
Partner - Creator
Author

First off, this is Qlik Sense, so qvw isn't an option.

Here's an example:

Data:

LOAD * INLINE [

    id, data

     1, ab-cde-efgh-ij-k-lm  

     2, abc-de-fg-hij-klm

];

NewData:

Load

     id,

     subfield(data, {fields1-4??}) as newdatafield

Resident Data;

Ideal end result:

id, newdatafield

1    ab-cde-efgh-ij

2     abc-de-fg-hij

Thanks

vishsaggi
Champion III
Champion III

May be try this?

LOAD *, LEFT(data, Index(data, '-',4)-1) AS NewDatafield INLINE [

id, data

1, ab-cde-efgh-ij-k-lm 

2, abc-de-fg-hij-klm

];