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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Split token Index

Hi all, I'm using Split function without second parameter in order to parse a column like this

abc | def | ghi

xxx| yyy | zzz

LOAD

SubField(col,'|') as col1,

col

resident S;

It creates a table with 3 rows

abc

def

ghi

and I would like to add a second column with index starting at 1 for each original row ..

abc     1

def      2

ghi      3

xxx     1

yyy     2

zzz     3

Do you know how to do it?

Thanks!

9 Replies
MK_QSL
MVP
MVP

LOAD

RowNO() as NO,

SubField(col,'|') as col1,

col

resident S;

UPDATE :

S:

Load * Inline

[

  col

  abc | def | ghi

  xxx| yyy | zzz

];

FINAL:

LOAD

  RowNo() as ID,

  TRIM(SubField(col,'|')) as col1,

  col

resident S;

Not applicable
Author

Thanks for your answer but it does not start in 1 for each original row so I obtain

abc     1

def      2

ghi      3

xxx     4

yyy     5

zzz     6

instead of

abc     1

def      2

ghi      3

xxx     1

yyy     2

zzz     3

MK_QSL
MVP
MVP

Check my enclosed file which i have updated later on...

Not applicable
Author

But I need the correct value in the "database" if you look in your file ID column doing Ctrl+Tyou will see 1,2,3,4,5,6

tresesco
MVP
MVP

For ID calculation try this in Manish's sample app:

Load

          If(col=peek('col'),peek('ID')+1, 1) as ID

MK_QSL
MVP
MVP

Like this?

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try this scirpt

Data:

LOAD

*,

If(Text <> Previous(Text), 1, peek('ID')+1) as ID;

LOAD

Text,

SubField(Text, '|') AS Value

INLINE [

Text

abc | def | ghi

xxx| yyy | zzz];

Regards,

Jagan.

Not applicable
Author

Hi

This is one more variant of solution:

Data:

Load * Inline

[

  col

  abc | def | ghi

  xxx| yyy | zzz

];

T:

LOAD

  -AutoNumber(col)+AutoNumber(col1) as ID,

  *;

LOAD

  TRIM(SubField(col,'|')) as col1,

  col

resident Data;

maxgro
MVP
MVP

load col, SubField(col, '|') as s, if(col<>peek(col), 1, peek(id)+1) as id;

LOAD * Inline [

col

abc | def | ghi

xxx| yyy | zzz

];

drop field col;