Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
christophebrault
Specialist
Specialist

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

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
1 Solution

Accepted Solutions
Not applicable

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;

View solution in original post

3 Replies
Anonymous
Not applicable

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

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


Not applicable

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;