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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
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.

Labels (1)
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
MVP
MVP

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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
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

];