Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

businessintelli
New Contributor III

Last 12 month and Previous 12 month

Hi,

I want to compare the Sum of sales for the last 12 month and for the previous 12 month on the scatter plot

For example, I compare these 2 dates : 12/03/2017 - 12/04/2018 and 12/03/2016 - 12/04/2017

I use this formula to calculate last 12 Month

Sum({<date={">=$(=timestamp(MonthStart(Today(),-12)))<=$(=timestamp(Today()))"}>}FactSoldAmount)


To compare Last 12 month to the Previous 12  month I wrote this, but it doesn't seem correct. Can someone help me ?



Sum({<date={">=$(=timestamp(MonthStart(Today(),-12)))<=$(=timestamp(Today()))"}>}FactSoldAmount)

-

Sum({<date={">=$(=timestamp(MonthStart(Today(),-24)))<=$(=timestamp(Today(),-12))"}>}FactSoldAmount)

5 Replies
sureshqv
Esteemed Contributor III

Re: Last 12 month and Previous 12  month


current 12months

=SUM({$<DateField = {'>=$(=YearStart(Today()))<=$(=MonthEnd(Today()))'}>}sales)

last 12months

=SUM({$<DateField = {'>=$(=AddMonths(YearStart(Today()),-12))<=$(=AddMonths(MonthEnd (Today()),-12))'}>}sales)

businessintelli
New Contributor III

Re: Last 12 month and Previous 12 month

I don't want current 12 Months.

Today is April I want to have all months from 2017 March to 2018 April and From 2016 March to 2017 April ---- I want something like this. And also, I should see the difference between these years

YoussefBelloum
Esteemed Contributor

Re: Last 12 month and Previous 12 month

Hi,

What is you Date field format ?

why do you use timestamp ?

Last 12 month and Previous 12  month

passionate
Valued Contributor

Re: Last 12 month and Previous 12 month

Previous 12 months can be best Achieved in data model.

PFA Solution.

naveenbandari14
New Contributor

Re: Last 12 month and Previous 12  month

Hello

am also new to qlik...I tried check check below expressions.

Mrach 2017-April 2018

=SUM({<OrderDate = {">=$(=YearStart(Today(),-1,3))<=$(=MonthEnd(Today()))"}>}Sales)

March 2016- April 2017

=SUM({<OrderDate = {">=$(=YearStart(Today(),-2,3))<=$(=YearEnd(Today(),-2,4))"}>}Sales)

Community Browser