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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
stephenedberkg
Creator III
Creator III

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 

Labels (1)
7 Replies
amit_saini
Master III
Master III

Stephan ,

See the attachment.

Thanks,

AS

jagan
Partner - Champion III
Partner - Champion III

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.

stephenedberkg
Creator III
Creator III
Author

Dears,

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

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

jagan
Partner - Champion III
Partner - Champion III

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.

stephenedberkg
Creator III
Creator III
Author

Re: Last month sales

Dear jagan

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

Regards,

Stephen Edberk

jagan
Partner - Champion III
Partner - Champion III

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.