Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
joey_lutes
Contributor

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

Re: Using subfield with multiple selections

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

];

4 Replies

Re: Using subfield with multiple selections

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

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
Honored Contributor

Re: Using subfield with multiple selections

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
Contributor

Re: Using subfield with multiple selections

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

Re: Using subfield with multiple selections

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

];