Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
chaper
Creator III
Creator III

How to find string value from Space separated String field

I have field with space separated multiple strings.I want to find a particular string value from that field.The position of that particular string value can be anywhere and it changes.How to find the particlar string?

thanks in advance

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think one to many is what you want. See attached example qvw.

data:

LOAD * Inline [

SNo, Source

1, DB2 SQL Oracle

2, SQL DB2 Excel

3, DB2 Oracle SQL Excel

4, Oracle Access

];

Types:

LOAD SNo,

  subfield(Source,' ') as Type

Resident data;

2015-06-12_10-57-11.jpg

-Rob

http://masterssummit.com

http://robwunderlich.com

View solution in original post

23 Replies
swuehl
MVP
MVP

What qualifies this special string value? Could you post some sample strings?

b_garside
Partner - Specialist
Partner - Specialist

There are a number of powerful String functions at your disposal. SubField() ,  Index() starting position of the n:th occurrence of sub-string, TextBetween()  as well. You will most likely need to Nest a couple of these functions.

If you provide some samples of these strings Im sure we can help give you some good starting points.

chaper
Creator III
Creator III
Author

String field example

Data Source

SQL DB2 Oracle

DB2 SQL Oracle

Excel Oracle SQL


I want to create group based on source type.

swuehl
MVP
MVP

And you want to transform these field values into what resulting table / field?

chaper
Creator III
Creator III
Author

I tried something like this

if(Index([Data Source],'SQL'),'SQL'),'SQL',

  if(Index([Data Source],'DB2'),'DB2'),'DB2'

    if(Index([Data Source],'Excel'),'Excel'),'Excel','Other') as Data Source Type

For example All string field values with SQL are not grouped as SQL,some values getting dropped??

chaper
Creator III
Creator III
Author

May be i wrongly interpreted the example field .this is how the field is

itemno   Datasource

   1        SQL ,DB2 ,Oracle

   2        DB2, SQL ,Oracle

   3.       Excel , Oracle ,SQL

chaper
Creator III
Creator III
Author

Each data item has Datasource labels/tags (Ex ,excel,sql,oracle).i want to group data items based on data source tags/labels.Sometimes each data item can share same or more than one tag.

swuehl
MVP
MVP

Try something like this:

MAP:

MAPPING LOAD F1, F1 as F2 INLINE [

F1

SQL

DB2

Oracle

Excel

];

LOAD itemno, [Data Source], applymap('MAP',trim(subfield([Data Source],' ')),'Other') as Group INLINE [

itemno, Data Source

1, "SQL ,DB2 ,Oracle"

2, "DB2, SQL, Oracle"

3, "Excel, Oracle ,SQL"

]

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Try:

subfield(String,' ') as Tag

-Rob