Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
aaronnayan
Creator III
Creator III

Variable for previous year sales

Hi guys,

I am trying to calculate sales for the previous year. I have made a variable as i thought it would be easier. When i make a selection i.e a month (feb 2017), i want this new measure to calculate the year before(Feb2016).


Currently it just shows the same sales as the selection made.

I have a date field,"Date1" and sales field "NetValue".


vLY= Year=,Month=,Week=,Day=,Date=,[Date1]={">=$(=date(addmonths($(vMinDate),-12)))<=$(=date(floor(addmonths(vMaxDate),-12))))"}


expression used =          sum({<$(vLY)>}NetValue)

I have also removed "Year=,Month=,Week=,Day=" from the variable and it makes no difference.


It still shows the same results as " sum(NetValue)"

is the variable wrong?

Thankyou!

4 Replies
rohan_chavan15
Contributor
Contributor

try using this for showing Sales of previous year in set analysis


{<MonthID=,Month=,Year={'$(=Max(Year)-1)'} ,Date={"<=$(=Max(Date))"}

aaronnayan
Creator III
Creator III
Author

Hi Rohan

Like this?

sum({<MonthID=,Month=,Year={'$(=Max(Year)-1)'} ,Date={"<=$(=Max(Date))"}NetValue)


MonthID is not a field and it does not work thankyou for trying

rohan_chavan15
Contributor
Contributor

sum({<Month=,Year={'$(=Max(Year)-1)'} ,Date={"<=$(=Max(Date))"}NetValue)



dnt use MonthID in exclusion hope this will work


aaronnayan
Creator III
Creator III
Author

Hi Rohan

It is still not working. When i used the variable it would actully return a value