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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using variable in dimension naming

Hi,

I want to iterate loading in script using variable, which usually works fine but this script halts reloading:

----

FOR i = 2 TO 6

  left join (MatTransProducts)

  load Distinct

  ParentObjID as IngredientObjectID$(i-1),

  ParentObjID as IngredientParentID$(i),

  IngredientObjectID1 as IngredientObjectID$(i),

  IngredientLotNo as IngredientLotNo$(i),

  IngredientItemNo as IngredientItemNo$(i),

  IngredientItemDesc as IngredientItemDesc$(i),

  IngredientItemType as IngredientItemType$(i)

  Resident MatTransProducts;

NEXT i

----

Is it the naming of fields using variable that need modification?

1 Solution

Accepted Solutions
sfatoux72
Partner - Specialist
Partner - Specialist

Hi,

You cannot do the  calculation $(i-1)

Try like this :

FOR i = 2 TO 6
let j=i-1;

left join (MatTransProducts)
load Distinct
ParentObjID as IngredientObjectID$(j),
ParentObjID as IngredientParentID$(i),
IngredientObjectID1 as IngredientObjectID$(i),
IngredientLotNo as IngredientLotNo$(i),
IngredientItemNo as IngredientItemNo$(i),
IngredientItemDesc as IngredientItemDesc$(i),
IngredientItemType as IngredientItemType$(i)
Resident MatTransProducts;

NEXT i

Regards

View solution in original post

2 Replies
sfatoux72
Partner - Specialist
Partner - Specialist

Hi,

You cannot do the  calculation $(i-1)

Try like this :

FOR i = 2 TO 6
let j=i-1;

left join (MatTransProducts)
load Distinct
ParentObjID as IngredientObjectID$(j),
ParentObjID as IngredientParentID$(i),
IngredientObjectID1 as IngredientObjectID$(i),
IngredientLotNo as IngredientLotNo$(i),
IngredientItemNo as IngredientItemNo$(i),
IngredientItemDesc as IngredientItemDesc$(i),
IngredientItemType as IngredientItemType$(i)
Resident MatTransProducts;

NEXT i

Regards

Anonymous
Not applicable
Author

Thanks - works!

Actually I left out the "=" I tried using in the i-j calculation: ParentObjID as IngredientObjectID$(=i-1)

... but that didn't work either. Adding a second variable works just fine.