Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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;
-Rob
What qualifies this special string value? Could you post some sample strings?
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.
String field example
Data Source
SQL DB2 Oracle
DB2 SQL Oracle
Excel Oracle SQL
I want to create group based on source type.
And you want to transform these field values into what resulting table / field?
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??
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
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.
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"
]
Try:
subfield(String,' ') as Tag
-Rob