Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
TKendrick20
Partner - Specialist
Partner - Specialist

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
Gysbert_Wassenaar

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
Chanty4u
MVP
MVP

Missing Capital "N"   in ur TableName

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

TKendrick20
Partner - Specialist
Partner - Specialist
Author

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

Gysbert_Wassenaar

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


talk is cheap, supply exceeds demand
TKendrick20
Partner - Specialist
Partner - Specialist
Author

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

Gysbert_Wassenaar

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