Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
Contributor II

Last month sales

How to calculate the last month sales values?

Eg:

=Sum({$<Year={$(=Max(Year))},MonthID={$(=Max(MonthID))}>}PrimarySales)

this above expression is currents month sales 

7 Replies
Highlighted
Honored Contributor III

Re: Last month sales

Highlighted
Honored Contributor III

Re: Last month sales

Stephan ,

See the attachment.

Thanks,

AS

Highlighted
MVP & Luminary
MVP & Luminary

Re: Last month sales

Hi,

If you have date field try like this

=Sum({$<Year=,MonthID=, DateDimensionName={'>=$(=MonthStart(Max(DateDimensionName), -1))<=$(=MonthEnd(Max(DateDimensionName), -1))'}>} PrimarySales)


Hope this helps you.


Regards,

Jagan.

Highlighted
Contributor II

Re: Last month sales

Dears,

   =Sum({$<Year={$(=Max(Year))},MonthID={$(=Max(MonthID-1))}>}Sales)

this above expression is correct or wrong for the last month sales

Highlighted
MVP & Luminary
MVP & Luminary

Re: Last month sales

Hi,

Let us assume if you select 2014 and Month as january then your expression will return

Null value because 1(Jan) - 1 gives you zero.

Hope this helps you.

Regards,

Jagan.

Highlighted
Contributor II

Re: Last month sales

Re: Last month sales

Dear jagan

  This kind of situation how to take the 2013 Dec values?

Regards,

Stephen Edberk

Highlighted
MVP & Luminary
MVP & Luminary

Re: Last month sales

Hi,

If you don't have date field then arrive the date field in script like below

LOAD

*,

MakeDate(Year, MonthID) AS DateDimensionName

FROM DataSource;


Now use below expression for getting the last month sales


=Sum({$<Year=,MonthID=, DateDimensionName={'>=$(=MonthStart(Max(DateDimensionName), -1))<=$(=MonthEnd(Max(DateDimensionName), -1))'}>} PrimarySales)


Hope this helps you.


Regards,

Jagan.