Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
james_hanify
Creator
Creator

Delimiting out and storing properly for an applymap

Hi all,

I've come into a scenario where I need to try and delimit out data which is on the same line and put them as new lines, i'm assuming some kind of loop is required but any assistance would be great.

My data structure is relatively simple as I use an SQL query to limit the results

Example data:

KeyMessage
JIGS*SALE*I1234

on Despatch # D123 D124

JIGS*SALE*I1235on Despatch # D125 D126 D127
JIGS*SALE*I1236on Despatch # D128 D130 D131

Turns into:

KeyMessage
JIGS*SALE*I1234D123
JIGS*SALE*I1234D124
JIGS*SALE*I1235D125
JIGS*SALE*I1235D126
JIGS*SALE*I1235D127
JIGS*SALE*I1236D128
JIGS*SALE*I1236D130
JIGS*SALE*I1236D131

Many thanks!

James

1 Solution

Accepted Solutions
sunny_talwar

Look at that... this worked too (I didn't think it would work for some reason )

Table:

LOAD Key,

  SubField(SubField(Message, '# ', 2), ' ') as Message;

LOAD * INLINE [

    Key, Message

    JIGS*SALE*I1234, on Despatch # D123 D124

    JIGS*SALE*I1235, on Despatch # D125 D126 D127

    JIGS*SALE*I1236, on Despatch # D128 D130 D131

];

View solution in original post

6 Replies
sunny_talwar

Try this:

Table:

LOAD Key,

  SubField(Message, ' ') as Message;

LOAD Key,

  SubField(Message, '# ', 2) as Message;

LOAD * INLINE [

    Key, Message

    JIGS*SALE*I1234, on Despatch # D123 D124

    JIGS*SALE*I1235, on Despatch # D125 D126 D127

    JIGS*SALE*I1236, on Despatch # D128 D130 D131

];

Anonymous
Not applicable

Hi James,

by using iter you can achieve above result example :

TABLE:

LOAD * INLINE [

    OBJECT, VALUE

    A, "123,456"

    B, 1234

    C, "136,1532,16323"

]

;

RESULT:

lOAD OBJECT, SubField(VALUE,',',ITERNO()) AS VALUE_RESULT

RESIDENT TABLE

WHILE(ITERNO()<=SubStringCount(VALUE,',')+1);

DROP TABLE TABLE;

Hope this helps,

vinieme12
Champion III
Champion III

or this

LOAD Key,

  subfield(right(Message,len(Message)-Index(Message,' #')-2),' ') as Message

;

Load * INLINE [

Key,Message

JIGS*SALE*I1234,on Despatch # D123 D124

JIGS*SALE*I1235,on Despatch # D125 D126 D127

JIGS*SALE*I1236,on Despatch # D128 D130 D131

];

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
sunny_talwar

Look at that... this worked too (I didn't think it would work for some reason )

Table:

LOAD Key,

  SubField(SubField(Message, '# ', 2), ' ') as Message;

LOAD * INLINE [

    Key, Message

    JIGS*SALE*I1234, on Despatch # D123 D124

    JIGS*SALE*I1235, on Despatch # D125 D126 D127

    JIGS*SALE*I1236, on Despatch # D128 D130 D131

];

stabben23
Partner - Master
Partner - Master

Or this one:

Load Key,
(
subfield(trim(SubField(Message,'#',-1)),' ')) as Message
;

Load * Inline [
Key, Message
"JIGS*SALE*I1234", "on Despatch # D123 D124"
"JIGS*SALE*I1235", "on Despatch # D125 D126 D127"
"JIGS*SALE*I1236", "on Despatch # D128 D130 D131"
]
;

james_hanify
Creator
Creator
Author

Brilliant! Thanks for the quick response, so subfield was the one to do this very efficiently.

James