Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Script to add column to table

Hi,

I need to add a new field to and existing table (shown below). The field is calculated using values from the previous record. The problem is that the new field is part of the formula.

The following script gives me this error: '[New Field] does not exist'. Any help would be appreciated.

T1:

Load

          *,

  if(PeriodID = 1, 1, Previous('[New Field]')-Previous('[Budget Contr]')) as [New Field]

Resident TableName;

PeriodIDPeriodBudget AmtBudget ContrNew Field
1Apr145886.000.07241.0000
2May178932.000.08880.9276
3Jun174902.000.08680.8388
4Jul182962.000.09080.7520
5Aug188201.000.09340.6612
6Sep178932.000.08880.5678
7Oct198880.500.09870.4790
8Nov196261.000.09740.3803
9Dec132587.000.06580.2829
10Jan132587.000.06580.2171
11Feb145886.000.07240.1513
12Mar158983.500.07890.0789
1 Solution

Accepted Solutions
jolivares
Valued Contributor

Re: Script to add column to table

Try this:

T1:

Load *,

     If(PeriodID = 1, 1, Peek([New Field])-Previous('[Budget Contr]')) as [New Field]

Resident TableName;

1 Reply
jolivares
Valued Contributor

Re: Script to add column to table

Try this:

T1:

Load *,

     If(PeriodID = 1, 1, Peek([New Field])-Previous('[Budget Contr]')) as [New Field]

Resident TableName;

Community Browser