Qlik Community

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.

christophebrault
Valued Contributor

Create field Year-1

Hi,

In the script, i have a table with the fields :

Date, CD_SOCIETY,CD_ENTITY,CD_PRODUT, VOLUME

I want to add a field VOLUME_N_1 wich is the value of VOLUME for last year using the field VOLUME.

How can i do this in the script please ?

Thanks

1 Solution

Accepted Solutions
Not applicable

Re: Create field Year-1

TRY THIS

LOAD *,

IF(YEAR=Max(YEAR), VOLUME) AS VOLUME_N_1;

LOAD

Date,

CD_SOCIETY,

CD_ENTITY,

CD_PRODUT,

VOLUME,

year(Date(Date)) AS YEAR

FROM TABLE;

3 Replies
jonbrough
Valued Contributor

Re: Create field Year-1

Do you mean that records in this year have an additional field that shows the total volume for last year for all products etc ?

Jonathan

Not applicable

Re: Create field Year-1

IF(Max(year(Date(Date,'YYYY'))) >0, VOLUME) AS VOLUME_N_1


Not applicable

Re: Create field Year-1

TRY THIS

LOAD *,

IF(YEAR=Max(YEAR), VOLUME) AS VOLUME_N_1;

LOAD

Date,

CD_SOCIETY,

CD_ENTITY,

CD_PRODUT,

VOLUME,

year(Date(Date)) AS YEAR

FROM TABLE;