Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculated value from "LOAD"

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:

Load

  `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

Any advise ?

5 Replies
tresesco
MVP
MVP

May be like attached sample?

CELAMBARASAN
Partner - Champion
Partner - Champion

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:

Load

  `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
Author

Hi,

I looked at your doc.

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

Thanks,

Anju

tresesco
MVP
MVP

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
Author

Hi,

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

-Anju