Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
Thanks, worked like a charm 😄