Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
How the looping is done with concatenation.
As of now I am loading data as
Actual:
Load
Month1,
Year1,
KeyData
Resident Temp;
Conatenate
Load
Month2,
Year2,
KeyData
Resident Temp;
Conatenate
Load
Month3,
Year3,
KeyData
Resident Temp;
Conatenate
Load
Month4,
Year4,
KeyData
Resident Temp;
Can we write a Loop statement so that it loops for 4 times with concatenating the data so that my code size decreases?
You missed ENDIF for second If statement
Temp:
LOAD * INLINE [
Key, Week1, Week2,Week3, Act1, Act2, Act3, For1, For2, For3, Zero
ABC, 1, 2, 3, 20, 30, 40, 20, 30, 40, Y
BCD, 1, 2, 3, 20, 30, 40, 15, 30, 100
DEF, 1, 2, 3, 20, 30, 40, 25, 50, 200
];
For i = 1 to 3
if ($(i)=1) then
Main:
Load
Key,
Week$(i) as Week,
Act$(i) as Act,
For$(i) as For,
Zero
Resident Temp;
ENDIF
if ($(i)>1) then
Concatenate
Main:
Load Key,
Week$(i) as Week,
Act$(i) as Act,
For$(i) as For
Resident Temp;
ENDIF
Next
Drop Table Temp;
Temp:
LOad * Inline [
KeyData,Month1,Year1,Month2,Year2
1,Jan,2011,Feb,2012
2,Jan,2011,Feb,2012 ];
For I = 1 to 2
Temp1:
Load
Month$(I) As Month,
Year$(I) As Year,
KeyData
Resident Temp;
Next
HI ,
What about concatenation?
If you have same field names, concatenation happens automatically
Temp:
LOad * Inline [
KeyData,Month1,Year1,Month2,Year2
1,Jan,2011,Feb,2012
2,Jan,2011,Feb,2012 ];
For I = 1 to 2
Concatenate
Load
Month$(I) As Month,
Year$(I) As Year,
KeyData
Resident Temp;
Next
What If i want to load
Key, Month1, Year1 seperately and then Concatenate the Looping Table.?
Because While loading Key, Month1, Year1 I will load one more calculated field and that field will not have value to other rows.
Like below:
Load
Month1 As Month,
Year1 As Year,
KeyData,
X+y = Z
Resident Temp;
Concatenate
For I = 2 to 3
Load
Month$(I) As Month,
Year$(I) As Year,
KeyData
Resident Temp;
Next
Temp1:
Load
Month1 As Month,
Year1 As Year,
KeyData,
X+Y As Z
Resident Temp;
For I = 2 to 3
Concatenate
Load
Month$(I) As Month,
Year$(I) As Year,
KeyData
Resident Temp;
Next
Am I doing some mistake?
I should Get only one table But
I am getting two tables with a SynTable.
Temp:
LOAD * INLINE [
Key, Week1, Week2,Week3, Act1, Act2, Act3, For1, For2, For3, Zero
ABC, 1, 2, 3, 20, 30, 40, 20, 30, 40, Y
BCD, 1, 2, 3, 20, 30, 40, 15, 30, 100
DEF, 1, 2, 3, 20, 30, 40, 25, 50, 200
];
For i = 1 to 3
if ($(i)=1) then
Main:
Load
Key,
Week$(i) as Week,
Act$(i) as Act,
For$(i) as For,
Zero
Resident Temp;
ENDIF
if ($(i)>1) then
Concatenate
Main:
Load Key,
Week$(i) as Week,
Act$(i) as Act,
For$(i) as For
Resident Temp;
Next
Drop Table Temp;
You missed ENDIF for second If statement
Temp:
LOAD * INLINE [
Key, Week1, Week2,Week3, Act1, Act2, Act3, For1, For2, For3, Zero
ABC, 1, 2, 3, 20, 30, 40, 20, 30, 40, Y
BCD, 1, 2, 3, 20, 30, 40, 15, 30, 100
DEF, 1, 2, 3, 20, 30, 40, 25, 50, 200
];
For i = 1 to 3
if ($(i)=1) then
Main:
Load
Key,
Week$(i) as Week,
Act$(i) as Act,
For$(i) as For,
Zero
Resident Temp;
ENDIF
if ($(i)>1) then
Concatenate
Main:
Load Key,
Week$(i) as Week,
Act$(i) as Act,
For$(i) as For
Resident Temp;
ENDIF
Next
Drop Table Temp;