
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Concatenating in For Each loop
At the first iteration of the loop I already need to have a table in order Concatenate to work.
Therefore I'm creating dummy fields before the loop and then dropping those fields when loop is finished.
Is there a neater way of getting around this?
SLAccounts:
LOAD * INLINE
[temp3, temp4
1, 1
];
for each CoName in 'Company1', 'Company2', 'Company3', 'Company4'
Concatenate
SLAccounts:
LOAD '$(CoName)' as CompanyName,
CustomerAccountNumber,
AccountBalance;
SQL SELECT CustomerAccountNumber,
AccountBalance
FROM "$(CoName)".dbo.SLCustomerAccount;
Next
drop fields temp3, temp4;
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if the tables contain the same column names then auto-concatenate will be applied by Qlik
so your script may be something like this:
For each CoName in 'Company1', 'Company2', 'Company3', 'Company4'
SLAccounts:
LOAD '$(CoName)' as CompanyName,
CustomerAccountNumber,
AccountBalance;
SQL SELECT CustomerAccountNumber,
AccountBalance
FROM "$(CoName)".dbo.SLCustomerAccount;
Next
and the final table will be called SLAccounts

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe like this:
SET vConcatenate = ;
For each CoName in 'Company1', 'Company2', 'Company3', 'Company4'
$(vConcatenate)
SLAccounts:
LOAD '$(CoName)' as CompanyName,
CustomerAccountNumber,
AccountBalance;
SQL SELECT CustomerAccountNumber,
AccountBalance
FROM "$(CoName)".dbo.SLCustomerAccount;
SET vConcatenate = Concatenate;
Next
talk is cheap, supply exceeds demand


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if the tables contain the same column names then auto-concatenate will be applied by Qlik
so your script may be something like this:
For each CoName in 'Company1', 'Company2', 'Company3', 'Company4'
SLAccounts:
LOAD '$(CoName)' as CompanyName,
CustomerAccountNumber,
AccountBalance;
SQL SELECT CustomerAccountNumber,
AccountBalance
FROM "$(CoName)".dbo.SLCustomerAccount;
Next
and the final table will be called SLAccounts

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tested in Sense, it highlights as error in script, but the script runs ok.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The issue I had that columns weren't the same and they did not concatenate correctly. Thanks.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Martyn
Did you find a way to script the loop without the visual error?
