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

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

derive new field from another field

i have

id=INS-2014-00001-FIN-00001-SUB-00001

using above field i want to derive below field in script

example:left(INS-2014-00001-FIN-00001-SUB-00001,24) as new_Field

INS-2014-00001-FIN-00001 as new_Field

is there any other way to split (Derive )

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

This may not look like anything, but unless you specify the exact formatting rules of this value, it will do the job. Let's call your source file MyField:

LOAD ....

     SubField(MyField, '-', 1) & '-' &

     SubField(MyField, '-', 2) & '-' &

     SubField(MyField, '-', 3) & '-' &

     SubField(MyField, '-', 4) & '-' &

     SubField(MyField, '-', 5) AS NewField

FROM ...;

If the SUB text is always present at the same position (and only there), you could also use

LOAD SubField(MyField, '-SUB', 1) AS NewField

FROM ...;

and there are other solutions but they depend on what format these values take.

Best,

Peter

View solution in original post

10 Replies
Siva_Sankar
Master II
Master II

=left('INS-2014-00001-FIN-00001-SUB-00001',24)

You just ignored to put your text inside single quote. Try the above.

Anonymous
Not applicable
Author

thanks for your time.

is there any other way to achieve the same .

i want to derive new field starting to before "SUB"

if i use left(24) in future it might not work

Siva_Sankar
Master II
Master II

=Subfield('INS-2014-00001-FIN-00001-SUB-00001','-SUB')

PrashantSangle

Hi,

use subfield()

try like

SubField('INS-2014-00001-FIN-00001-SUB-00001','-SUB') as newField

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
MayilVahanan

Hi'

Try like this

LOAD *, Mid(id, Index(id, 'SUB')) as newid Inline

[

id

INS-2014-00001-FIN-00001-SUB-00001

];

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Peter_Cammaert
Partner - Champion III
Partner - Champion III

This may not look like anything, but unless you specify the exact formatting rules of this value, it will do the job. Let's call your source file MyField:

LOAD ....

     SubField(MyField, '-', 1) & '-' &

     SubField(MyField, '-', 2) & '-' &

     SubField(MyField, '-', 3) & '-' &

     SubField(MyField, '-', 4) & '-' &

     SubField(MyField, '-', 5) AS NewField

FROM ...;

If the SUB text is always present at the same position (and only there), you could also use

LOAD SubField(MyField, '-SUB', 1) AS NewField

FROM ...;

and there are other solutions but they depend on what format these values take.

Best,

Peter

er_mohit
Master II
Master II

Try this

Left('INS-2014-00001-FIN-00001-SUB-00001',index('INS-2014-00001-FIN-00001-SUB-00001','-',5)-1)

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

LOAD

*,

Subfield('INS-2014-00001-FIN-00001-SUB-00001','-SUB', 1) AS NewFieldName

FROM DataSource;


Hope this helps you.


Regards,

Jagan.

Anonymous
Not applicable
Author

hi

LOAD SubField(MyField, '-SUB', 1) AS NewField

its worked for me .

thanks all