Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

balajisj30
New Contributor III

Building chart with selected year and previous year

Hi People

I have a requirement to compare sales of selected year and previous year.

I have used this expression to show previous year data,

=Sum({$<acc_period_year={"$(=acc_period_year-1)"}>}bill_size)

When i select a single year, the chart is displayed.

qlik issue1.PNG

But when i select 2 years in filter pane, the chart (previous year) is not working.

qlik issue2.PNG

Please let me know the expression which i could use to display previous year (even when more years are selected).

Thanks

Balaji

5 Replies

Re: Building chart with selected year and previous year

Try this

=Sum({$<acc_period_year={"$(=Max(acc_period_year)-1)"}>}bill_size)

Because when you have selected 2 years, acc_period_year cannot decide which of the two values do we need to use, we add Max() function to pick the bigger of the two years selected

agigliotti
Honored Contributor II

Re: Building chart with selected year and previous year

maybe this:

=Sum({$<acc_period_year={"$(=Min(acc_period_year)-1)"}>}bill_size)

balajisj30
New Contributor III

Re: Building chart with selected year and previous year

Thanks for the reply Sunny Talwar.

Your expression considers only max of the selected years and gives values for the previous year.

But i need expression which displays previous year sales of all the selected years.

example

if i select 2017 & 2015 in filter pane.

I should get sales value of year 2016 & 2014 in the previous year chart.

balajisj30
New Contributor III

Re: Building chart with selected year and previous year

Thanks for the reply Andrea Gigliotti.

Your expression considers only min of the selected years and gives values for the previous year.

But i need expression which displays previous year sales of all the selected years.

example

if i select 2017 & 2015 in filter pane.

I should get sales value of year 2016 & 2014 in the previous year chart.

mikerales
New Contributor

Re: Building chart with selected year and previous year

Hello,

 

"But i need expression which displays previous year sales of all the selected years."

 

I have the very same need.

Does anyone have a solution? 

Thanks!

Community Browser