Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner
Partner

Qlik Sense Script Line Error on For Loop in Version 2.2.0

I have a script that used to work with previous versions and definitely worked in QlikView:

[tmpTable]:

Generic Load * Resident [Demographic Responses];

[Demographic Information]:

Load Distinct [Respondent ID] as [Respondent ID]

Resident [Demographic Responses];

FOR i = 0 to NoOfTables()

TableList:

  Load TableName($(i)) as [TableName] AUTOGENERATE 1

  WHERE WildMatch (TableName($(i)), 'tmpTable.*');

NEXT i

FOR i = 1 to FieldValueCount('Tablename')

  LET vTable = FieldValue('Tablename', $(i));

  LEFT JOIN ('Demographic Information') LOAD * RESIDENT [$(vTable)];

  DROP TABLE [$(vTable)];

NEXT i

Drop Tables [Demographic Responses], TableList;

The first For loop works, but the second does not for some reason. I assure you there is NO problem with the data in [Demographic Responses]. I've tried other types of loops and I am out of ideas. I get the following error every time:

Qlik Sense Line Error.PNG

6 Replies
Highlighted
MVP & Luminary
MVP & Luminary

Load TableName($(i)) as [TableName] AUTOGENERATE 1 

FOR i = 1 to FieldValueCount('Tablename')

TableName and Tablename are two different fields. So, just a typo.


talk is cheap, supply exceeds demand
Highlighted
Champion III
Champion III

Missing Capital "N"   in ur TableName

u shud use the same fieldnames or table names same for entire document.

Highlighted
Partner
Partner

That has been corrected, still the same error. I was testing a bunch of different things which is why that mistake is in the original question. I have also tried:

  • While -> Loop instead of For -> Next
  • Doing  "FieldValueCount('Tablename') STEP 1"
  • The table names include spaces which I replaced with "_"

In debugging I'm seeing some weird things happen where the variable "i" is exceeding the actual count of field values and then the loop is breaking. I'll keep at it

Highlighted
MVP & Luminary
MVP & Luminary

I saw you read another similar discussion. Did you enable the legacy mode as mentioned in that discussion?


talk is cheap, supply exceeds demand
Highlighted
Partner
Partner

I have not. This is Qlik Sense server I'm working on. Does it still work with that?

Highlighted
MVP & Luminary
MVP & Luminary

Yes, unfortunately it's a server wide setting. And it has security implications so this is not a step to take lightly. See Qlik Sense Legacy mode for more information.


talk is cheap, supply exceeds demand