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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
darrinturner
Contributor II
Contributor II

Load Script error?

Hello all,

I am hoping someone can point out what I am clearly missing with load script.

I am the following which creates a master linked table.

 

 

Let vAssociationTableName = 'AssociationTable';

$(vAssociationTableName):
LOAD * INLINE [
_FactCounter
1
] WHERE 1 = 0;

LET vNoOfTables = NoOfTables();
FOR vTableNumber = 0 to ($(vNoOfTables) -1)
LET vTableName = TableName($(vTableNumber));
LET vTempTableName = '$(vTableName)';
IF Right('$(vTableName)',7) = '_NOLOAD' THEN
LET vTempTableName = Left('$(vTableName)',(Len('$(vTableName)')-7));
END IF
LET vFactFieldName = '_Fact_' & '$(vTempTableName)' & 'Key';
IF FieldNumber('$(vFactFieldName)','$(vTableName)') > 0 THEN
LET vLoadString = 'CONCATENATE (' & '$(vAssociationTableName)' & ') ' & Chr(13) & Chr(10) & 'LOAD DISTINCT ' & '$(vFactFieldName)' & Chr(13) & Chr(10);
LET vNoOfFields = NoOfFields('$(vTableName)');
FOR vFieldNumber = 1 to $(vNoOfFields)
LET vFieldName = FieldName($(vFieldNumber), '$(vTableName)');
IF Left('$(vFieldName)',1) = '_' AND Right('$(vFieldName)',2) = 'ID' AND Left('$(vFieldName)',6) <> '_Fact_' THEN
LET vStringStart = Index('$(vFieldName)','_',-1);
LET vStringEnd = (Len('$(vFieldName)') - 2);
LET vStringLen = $(vStringEnd) - $(vStringStart);
LET vThisField = Mid('$(vFieldName)', ($(vStringStart)+1), $(vStringLen));
LET vThisFactField = '_Fact_' & '$(vThisField)' & 'Key';
IF '$(vThisFactField)' <> '$(vFactFieldName)' AND ISNULL(TableNumber('$(vThisField)')) = 0 THEN
LET vLoadString = '$(vLoadString)' & ',' & '$(vFieldName)' & ' AS ' & '$(vThisFactField)' & Chr(13) & Chr(10);
END IF
END IF
NEXT ;
LET vLoadString = '$(vLoadString)' & ', ' & 'TableName($(vTableNumber))' & ' AS _FactType' & Chr(13) & Chr(10);
LET vLoadString = '$(vLoadString)' & ',1 AS _FactCounter' & Chr(13) & Chr(10);
LET vLoadString = '$(vLoadString)' & 'RESIDENT ' & '$(vTableName)' & ';' ;
$(vLoadString)
End If
NEXT ;

 

The script is adding pink highlight to the last "End if" as seen below, but I can not figure out why. I should also add that it runs fine and does what I am aiming to do.

What are your thoughts?

Thank you in advance.

 

loadscriptError.PNG

1 Reply
raji6763
Creator II
Creator II

hi @darrinturner ,

Could you please remove the variable?( in line no.36) ?

$(vLoadString)

End If

then check the code

 

raji6763_0-1594284700390.png

 

regards,

raji

 

 

Regards,

raji