Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

compare current year previous year

I want to compare the current year with  previous year

for example

its booked until 201404

i want t show the sales for sum(maxyear) : Jan/Feb/Mar/Apr 2014

and compare it with sum(sales) : Jan/Feb/Mar/Apr 2013

17 Replies
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Create a table with those expressions with Month Year as the dimensions, you can then see what is going on.

Add an additional measure to this table of just SUM(Sales), this will give you the amounts you are after in each month.

Try building up the set analysis a bit at a time; e.g. just do the >=YearStart first.

In fact, unless you have future sales values you don't need the <= on the Current Year values.

Set analysis can be quite funny about date formats.  You may need to use the Date function to format the output from YearStart and MonthEnd to be in the same format as your Date field.

Hope that helps.

Steve

its_anandrjs

The expressions that you use is ok for me please check what the Steve suggested to you, may be doing some mistake in set analysis.

Anonymous
Not applicable
Author

you mean inline table?

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Just a straight table chart.  You could copy your existing one and change the dimension.

Anonymous
Not applicable
Author

now its functioning well but ,if i want to compare 2015 sales with 2017 in same chat .here  only 2016 AND 2017 SALES CAN BE SEEN WHEN YEAR DIMENSION WAS TAKEN paint.png

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

You need another expression with AddYears and -2 in there as the parameter.

Anonymous
Not applicable
Author

paint1.png

i have written expression on 2016 label as following :-

=num(sum({< sold_Year = {"$(=Max(sold_Year))"}>} [inv value]/Sales_INR_Unit),'#,##0.0')

now you want me to add another expression?

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Sorry, I read it as you wanted to show three years in separate columns.  Is it that you want to keep current year ffixed, but change which year you compare to?

If so, you will need to change the years back value to a variable, say vYB and insert that into the expression like this:

=SUM({$<Date = {'>=$(=YearStart(AddYears(Today(),-$(vYB))))<=$(=MonthEnd(AddYears(Today(),-$(vYB))))'}>}Sales)


This will need to be created under Settings \ Variables, and then controlled by a pair of buttons.  See this post for details on changing variables with buttons:

https://www.quickintelligence.co.uk/qlikview-buttons/

Hope that helps.