Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING
cancel
Showing results for 
Search instead for 
Did you mean: 
Kain_F
Contributor II
Contributor II

RENAMING FIELDS IN FOR LOOP

Hey,

 

I have a question regarding renaming fields in a FOR LOOP.

I have the following data:

 

DATA1:

TEAM NUMBER OTHER
4 1 4
4 17 5
2 15 8
1 4 6
1 8 9

 

DATA2:

DIVISION NUMBER OTHER
3 6 3
2 8 5
2 2 4
1 18 7
2 6 5

 

DATA3:

DIVISION NUMBER
4 7
1 19
5 1
1 15
1 16

 

The field 'Division' in DATA2 is the same as the field 'TEAM' in DATA1.

The field 'Other' does not exist in DATA3.

 

What I have now is the following:

 

let vI = 1

let vJ = 3

set ErrorMode = 0

FOR i to j

let vConnector = 'connection' & 'DATA' & vI & '.qvd'

load 

*

FROM [vConnector](qvd);

if ScriptError = 11 then

load 

*

FROM [vConnector](qvd);

next;

 

What I need is something like this:

FOR i to j

let vConnector = 'connection' & 'DATA' & vI & '.qvd'

load 

*

FROM [vConnector](qvd);

if field = 'Division' then

load

*,

DIVISION as TEAM

FROM [vConnector](qvd);

endif;

if ScriptError = 11 then

load 

*

FROM [vConnector](qvd);

endif;

next;

 

Thanks a lot for helping out

 

 

Labels (4)
1 Solution

Accepted Solutions
rwunderlich

I think you may be making this more difficult than necessary.  Add an Alias statement at the beginning of your script. 

ALIAS DIVISION as TEAM;

Data:
LOAD * From ...
Concatenate (Data)
Load * From ...
etc

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

View solution in original post

2 Replies
rwunderlich

I think you may be making this more difficult than necessary.  Add an Alias statement at the beginning of your script. 

ALIAS DIVISION as TEAM;

Data:
LOAD * From ...
Concatenate (Data)
Load * From ...
etc

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

View solution in original post

Kain_F
Contributor II
Contributor II
Author

@rwunderlich  

Thanks, worked like a charm 😄