Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
nkumarkanduri
Contributor II
Contributor II

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.

1 Solution

Accepted Solutions
Vegar
MVP
MVP

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

 

View solution in original post

2 Replies
Vegar
MVP
MVP

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

 

nkumarkanduri
Contributor II
Contributor II
Author

Thanks for your help. It fixed the issue.