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: 
Anonymous
Not applicable

Overwrite a field with a calculated filed within the same script

HI, This works but i'm looking to condense it to one Load if possible to reduce script run time and memory/CPU usage usage - tables are millions of rows in size.    I need to clean out everything in the Agent field past the ":", but the field name must remain as Agent in the final data.   

DATASET_2:

Load *

,left(Agent,index(Agent,':')-1) as Agent2

Resident DATASET;

DROP table DATASET; 

Drop field Agent;

DATASET_3:

,Agent2 as Agent

,*

Resident DATASET_2;

DROP table DATASET_2; 

Thanks,
Dave

Labels (1)
1 Solution

Accepted Solutions
Anil_Babu_Samineni
MVP
MVP

You can't do like this? This makes better where you expected

DATASET:

Load @1, @2, Agent, left(Agent,index(Agent,':')-1) as Agent2;

OR

DATASET:

Load @1, @2, Agent, left(Agent,index(Agent,':')-1) as Agent2;

Drop Field Agent From DATASET;

RENAME Field Agent2 to Agent;

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

4 Replies
techvarun
Specialist II
Specialist II

Try the below code in your first load itself like below

DATASET:

LOAD left(Agent,index(Agent,':')-1) as Agent FROM ......


You can eliminate all the other steps Dateset2,dataset3, Resident, Drop field etc


Thanks,

Varun

Anil_Babu_Samineni
MVP
MVP

You can't do like this? This makes better where you expected

DATASET:

Load @1, @2, Agent, left(Agent,index(Agent,':')-1) as Agent2;

OR

DATASET:

Load @1, @2, Agent, left(Agent,index(Agent,':')-1) as Agent2;

Drop Field Agent From DATASET;

RENAME Field Agent2 to Agent;

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
techvarun
Specialist II
Specialist II

Or You can try

DATASET:

LOAD SubField(Agent,':',1) as Agent FROM ......


Anonymous
Not applicable
Author

Thanks both, Rename Field was the trick I was looking for.

Varun, I couldn't do it that way because I was also loading all fields "*" so it was causing a column name conflict error.  I'll try the subfield formula though, thanks for that.