
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problem with for each loop
Hello All,
I am just trying to create new tables which contains only the information of certain business unit and naming the table with business unit. But when I am using field value list to get the unique values of business units and then use them in the loop Somehow I am getting an error. Please find below for more information.
Thanks in Advance,
Nithin.
Code part:
Table1:
LOAD
ACTIVITY_ID,
ACTIVITY_TYPE,
ACTIVITY_DATE,
EMAIL,
ASSET_NAME,
SUBJECT_LINE,
"URL",
ASSET_CATEGORY,
ASSET_SPEC_NUM,
ASSET_LANGUAGE,
ASSET_PRODUCT_CATEGORY,
ASSET_PRODUCT_SUB_CATEGORY,
DIVISION,
BUSINESS_UNIT,
FAMILY,
ASSET_TYPE,
CASE_NUMBER,
CASE_OWNER_EMAIL,
MPN,
ASSET_COMMUNITY,
ASSET_SUB_TYPE,
EMAIL_TRACKED,
ACTIVITY_AGE_DAYS
FROM [lib://QVD_Files_Public/FACT_ACTIVITIES.qvd]
(qvd);
FOR Each a in FieldValueList('BUSINESS_UNIT')
$(a):
LOAD * Resident Table1 where BUSINESS_UNIT=$(a);
NEXT a
Error part:
Field 'FBU' Not found.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As I don't see your data and not the script I can only guess what's wrong, but I see twoof potential issues, table name and the where clause. Try this loop where I've done some adjustment to your script.
FOR Each a in FieldValueList('BUSINESS_UNIT')
[$(a)]:
LOAD *
Resident Table1
where BUSINESS_UNIT='$(a)';
NEXT a
Qlik Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As I don't see your data and not the script I can only guess what's wrong, but I see twoof potential issues, table name and the where clause. Try this loop where I've done some adjustment to your script.
FOR Each a in FieldValueList('BUSINESS_UNIT')
[$(a)]:
LOAD *
Resident Table1
where BUSINESS_UNIT='$(a)';
NEXT a
Qlik Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help. It fixed the issue.
