Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

ludvigholmberg
New Contributor

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
Partner
Partner

Re: Using variable in dimension naming

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
Partner
Partner

Re: Using variable in dimension naming

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

ludvigholmberg
New Contributor

Re: Using variable in dimension naming

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.