# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

#### Breathe easy -- you now have more time to plan your next steps with Qlik! QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

New Contributor II

Hi everybody,

i need to calculate a value in the script.

I have a table with field  YEAR , MONTH , INFLACTION (that doesn't change in the same YEAR) and INFLACTION FACTOR (this is the field that i need to calculate, now i put "1" in every record)  like:

DAT:

YEAR , MONTH , INFLACTION , INFLACTION FACTOR

2010 ,  10 , 1 , 1

2010 , 11 , 1 , 1

2010, 12 , 1 , 1

2011 , 1 , 3 ,1

2011 , 2 , 3 , 1

2011 , 3 , 3 ,1

......

2011 , 10 , 3 , 1

2011 , 11 , 3 ,1

2011 , 12 , 3 , 1

2012 , 1 , 5 , 1

2012, 1 , 5 , 1

INFLACTION FACTOR = INFLACTION FACTOR (of the previus year)  * ( 1 + INFLACTION)

and the first year is 1

DAT_GROUP:

`dat.year` as `dat_group.year`,

`dat.month` as `dat_group.month`,

`dat.INFLATION` as `dat_group.INFLATION`,

if(Previous(`dat.year`)=(`dat.year`),Previous(`dat_group.InflationFactor`),(Previous(`dat_group.InflationFactor`)*(`dat.INFLATION`+1)))

Resident DAT;

but i can't read the value of the new table in the LOAD function.

`dat_group.InflationFactor`   ---> launch an error

5 Replies
MVP

## Re: Calculated value from "LOAD"

May be like attached sample?

MVP

## Re: Calculated value from "LOAD"

I hope you have applied Qualify, so you where using table names before the field name. But you should no use table name before the field that is not yet created. Qualify is only applied after the table gets created.

Try the below

DAT_GROUP:

`dat.year` as `dat_group.year`,

`dat.month` as `dat_group.month`,

`dat.INFLATION` as `dat_group.INFLATION`,

if(Previous(`dat.year`)=(`dat.year`), Peek('InflationFactor'), (Peek('InflationFactor') * (`dat.INFLATION`+1))) AS InflationFactor

Resident DAT;

Not applicable

## Re: Calculated value from "LOAD"

Hi,

But, how does the logic you wrote in the first line override the inline load?

Thanks,

Anju

MVP

## Re: Calculated value from "LOAD"

Hi Anju,

AFAIK, it is qv's default behaviour that it takes the earlier table reference when is referred from following table during load.

Not applicable

## Re: Calculated value from "LOAD"

Hi,

It is a nice way of using our logic combined with inline data.

-Anju

Community Browser