Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Previous values

Sometimes I need to have in a pivot table but for others calculations as well the amount of a previous values

e.g.:

YearSalesSales (year-1)
2010890-
2011900890
2012700900

Without using before o above is it possible to obtain this result?

I thought to use set analysis .. but I got some problem with that. And actually I don't have a current selection on because I am showing all the possible Year.

Thank in advance

7 Replies
richard_chilvers
Specialist
Specialist

Using ABOVE works well - is there a reason you cannot ?

Regards

richard_chilvers
Specialist
Specialist

....although, I suppose it would not give what you want if you had a year with no values in the data at all

SunilChauhan
Champion II
Champion II

use Below code

Tab1:

Load * inline [

Year,          Sales

2010,          890

2011,          900

2012          ,700

];

load *,

previous( Sales) as prev

resident Tab1;

drop table Tab1;

and in dimension take Year and in first expression Sales  and in second expression take prev

and chart properties-> presentation->supress zero value->uncheck

hope this help

Sunil Chauhan
jagan
Partner - Champion III
Partner - Champion III

Hi,

Please find the attached for solution.

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

I really think this is the only way (through the script ) .... do you think that I can do the same with a set analisys?

Thanks again

Not applicable
Author

Why this expression doesn't work ?

sum({$<Year = {$(#=Only(Year)-1)}>} Sales )

SunilChauhan
Champion II
Champion II

try this

sum({$<Year ={$(=only(Year)-1)}>} sales )

this will work on selections of years

Sunil Chauhan