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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Alessandro87
Contributor III
Contributor III

Subfield + AutoNumber(RowNo() or similar

Hello,

I have a field that is composed like this:

/123-abc-456/321-bca-654/789-cvb520/489-gty-663

what I need is to extract each value so subfield(field, '/') as field

but I have to assign an incremental index to each values, so at the end I will have:

field 123-abc-456 depth 1

field 321-bca-654 depth 2

 

etc...

 

Any ideas on how to do it? (of course the field is random, can't use if(...then...

 

Many thanks!

Labels (2)
1 Solution

Accepted Solutions
marcus_sommer
MVP
MVP

Maybe with a self-join, like:

inner join(YourTable) load X, max(Z) as Z resident YourTable group by X;

View solution in original post

5 Replies
marcus_sommer
MVP
MVP

It could be simply reached with a while-loop and subfield(), for example with:

load *, subfield(Field, '/', iterno()) as X, iterno() as Y
from Source while iterno() <= substringcount(Field, '/') + 1;

rwunderlich
MVP
MVP

You can use AutoNumber as you suggested in a preceding load.

Data:
LOAD *,
AutoNumber(field, Key) as depth
Where len(field) > 0
;
LOAD *,
RecNo() as Key,
Trim(SubField(raw,'/')) as field
Inline [
raw
/123-abc-456/321-bca-654/789-cvb520/489-gty-663
/788-xyz-456/999-bca-654/1111-cvb520/22-gty-663/rob-xyz
];

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

Alessandro87
Contributor III
Contributor III
Author

It worked, thanks.

Now I have this situation, and I have to extract only distinct y,x value that match this condition:

max value of z

Alessandro87_0-1722345322379.png

every values is created randonly by the BE, so can't use any if(x=to...then...) or inline.

I have to extract it in the load editor script while loading data from the DB.

 

Thanks!

marcus_sommer
MVP
MVP

Maybe with a self-join, like:

inner join(YourTable) load X, max(Z) as Z resident YourTable group by X;

Alessandro87
Contributor III
Contributor III
Author

Worked! Thank you!