Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

get past year data

Hi,

when I selected 2014 in my year list box, I want to get the 2013 sales data. How can I do this in a chart expression?

1 Solution

Accepted Solutions
Colin-Albert

Sum({<Yr={$(=max(Yr) -1)}>} data)

Yr is your year field,  data is the field you are summing

View solution in original post

19 Replies
Colin-Albert

Sum({<Yr={$(=max(Yr) -1)}>} data)

Yr is your year field,  data is the field you are summing

arulsettu
Master III
Master III

like this

sum({<year={$(=max(year)-1)}>}sales)

Not applicable
Author

Hi,

max(year) means current year or selected year?

arulsettu
Master III
Master III

if your year field like this

2011,2012,2013,2014

max(years) will give 2014

Not applicable
Author

Hi arul,

If I selected 2013 in my year list box, is it showing 2012 data for the result?

arulsettu
Master III
Master III

yes based on your selection it will give previous year

sunilkumarqv
Specialist II
Specialist II

for curren year =Max(Year) =2014

For Prev Year =Max(Year)-1=2013

in set analysis you need to define like below  and also include year=

Sum({<Year={$(=Max(Year)-1)},Year=>}value)

Not applicable
Author

But the problem is when I selected year=2014 and month=12, I m getting same results for the two columns. why is that?

these are my expressions in my chart.

Num(Sum({<Year={'$(=Max(Year)-1)'},Year=>}Retail_Sale_Qty),'#,##0') - prev year

Num(Sum(Retail_Sale_Qty),'#,##0') - selected year

ashfaq_haseeb
Champion III
Champion III

Hi try like this

Num(Sum({<Year={'$(=Max(Year)-1)'}>}Retail_Sale_Qty),'#,##0') - prev year

Num(Sum(Retail_Sale_Qty),'#,##0')

Regards

ASHFAQ