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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Compare data of two years (Set Analysis)

Hi,

I'm searching for a way to compare the data of two years for the active months.

At the moment I got data for January - March 2011. I'd like to compare this data to January - March 2010. And at the next month January - April 2011 with January - April 2010.

I tried it like this, but in case of {"01"}+{"02"} it has to be variable:
=sum({<CalendarYear={$(=max(Year_Orders)-1)},Month_num_Orders={"01"}+{"02"}+{$(=right(max(Year_Month_num_Orders),2))}>}Orders_All_Orders)

Explanation (for example):
Year_Orders = 2011, 2010 ...
Month_num_Orders = 01, 02 , 03 , 04 ... 11, 12
Year_Month_num_Orders = 201101, 201102 ... 201111, 201112 ...
Orders_All_Orders = the amount of orders

Did anybody know a solution for my problem?

Many Thanks!

3 Replies
brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi, Hernandez,

you can use YearToDate-function in the script, it is a flag True=-1:

YearToDate(Datefield,0)*-1 As YTDActual
YearToDate(Datefield,-1)*-1 As YTDLastYear

Than in the expression:

Sum({<Year_Orders={$(=Only(Year(Today())))}>} Sales*YTDActual)

Sum({<Year_Orders={$(=Only(Year(Today())-1))}>} Sales*YTDLastYear)

Not applicable
Author

Hi,

Take a pivot table add months as one dimention to that.

and add two expresions:

sum({<Year={"2011"}>} Orders_All_Orders) ,lable it as 2011

sum({<Year={"2010"}>} Orders_All_Orders) ,lable it as 2010

then drag month column in pivot table to horizantal.

I hope it will solve your problem....

Anonymous
Not applicable
Author

If you want to compair up to the same date (and you have a date field) you can use:

Sum({$<Year={$(=Max(Year)-1)},
Datefield={'<=$(=AddYears(Today(),-1))'}
>}
AmountOrders)

I hope you can use this.