Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

aaronnayan
Contributor

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
New Contributor

Re: Variable for previous year sales

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


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

aaronnayan
Contributor

Re: Variable for previous year sales

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
New Contributor

Re: Variable for previous year sales

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



dnt use MonthID in exclusion hope this will work


aaronnayan
Contributor

Re: Variable for previous year sales

Hi Rohan

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