Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
alina_qlik
Contributor III
Contributor III

Please help on Script to create new field from existing and duplicate value ?

Hello Fellas ,

A newbie here . I want to create two new fields and repeat values in those .  This being unkown domein  fr me  , if this gonna be huge script ?

Sourcing data 

IDDCIPUACCLASS
S1DC1alpha-ketofirst
S1DC2 second
S1DC3 third
S1DC4 fourth
S2DC1 first
S2DC2omega-ketosecond
S3DC1 third
S3DC2 fourth
S3DC3 first
S3DC4alpha-cyclicsecond
S3DC5 second

 

Out data 

IDDCIPUACCLASSRORNEWFIELD1NEWFIELD2
S1DC1alpha-ketofirst0.8alphaketo
S1DC2 second0.2alphaketo
S1DC3 third0.5alphaketo
S1DC4 fourth0alphaketo
S2DC1 first0.8omegaketo
S2DC2omega-ketosecond0.2omegaketo
S3DC1 third0.8alphacyclic
S3DC2 fourth0.2alphacyclic
S3DC3 first0.5alphacyclic
S3DC4alpha-cyclicsecond0alphacyclic
S3DC5 second0.8alphacyclic

 

nf.PNG

2 Replies
Ksrinivasan
Specialist
Specialist

hi,

1. is it Straight table?

2. what based you have give value as alpha?

Steven_Haught
Creator III
Creator III

In a new section in your load below your original you could try the following:

Finaltab:


Load
*,
SubField(IPUAC_temp,'-',1)as NewField1,
SubField(IPUAC_temp,'-',2)as NewField2
;

Load
*,If(Len(Trim(IPUAC)), IPUAC, Peek(IPUAC_temp)) AS IPUAC_temp
;


Load
*

Resident YOURTABLENAME
order by IDnew asc, IPUAC desc ;
Drop Table YOURTABLENAME;

 

My results from using the above.

Steven_Haught_0-1597346772189.png