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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis

I have a report that that has past actual sales and future forecast data. I need help with a set analysis to create a field in a straight chart. Currently, the chart shows the future forecast with week numbers.... (i.e 201436, 201437, 201438 and so on)


I want to create one field that shows the sales associated with the same week from the previous year and another field that shows the sales from two years back from current year. So if I select 201436 through 201452, I want column 1 to show actual sales for 2013 from week 36 through 52. I want column 2 to show actual sales for 2012 from week 36 through 52.



yr/wkproductregionforecastcolumn1 (sales from 1 year previous)column2 (sales from 2 year previous
201436awest200194165
201437beast400345300


so column1 is 'actual sales' from year 2013 for weeks 36 and 37. column2 is 'actual sales from year 2012 for weeks 36 and 37

1 Reply
JonnyPoole
Former Employee
Former Employee

Take a look at the attached

I use a series of variable as follows

vMaxSelectedDate =   max(Date)   ---> most recent date in user's selections

vMinSelectedDate =   min(Date)   ---> oldest date in user's selections

vMaxSelectedDate1YearAgo =  AddYears( max(Date),-1)   ->   Most recent date in user's selection minus 1 whole year

vMinSelectedDate1YearAgo =  AddYears( min(Date),-1)   ->  oldest date in user's selection minus 1 whole year

vMaxSelectedDate2YearsAgo =  AddYears( max(Date),-2)   ->   Most recent date in user's selection minus 2 whole years

vMinSelectedDate2YearsAgo =  AddYears( min(Date),-2)   ->  oldest date in user's selection minus 2 whole years

Then the expressions to grab the date range from a year prior and 2 years prior becomes straight forward

Previous Year Sales:

sum(  {$< Year=,MonthName,Month=, Date= {'>= $(=num(vMinSelectedDate2YearsAgo))<=$(=num(vMaxSelectedDate2YearsAgo))'}>}  Sales)

2 Years ago Sales:

sum(  {$< Year=,MonthName,Month=, Date= {'>= $(=num(vMinSelectedDate2YearsAgo))<=$(=num(vMaxSelectedDate2YearsAgo))'}>}  Sales)