Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get Previous Month

Hi Guyys,  i want to Find Out Previous Month Method. Suppose I have a One Year 2015 and 2014.. In that I want to

Compare the sum of sales month wise.. Like If I select 2015 as a Year and dec as a Month. so i get the Sum of sales

for Dec and Nov . as well if i select Year 2015 and Month Jan i get the sum of sales for Jan and Dec2014..

Kindly Help me ..

14 Replies
amit_saini
Master III
Master III

Hi,

Like this???

Thanks,

AS

Not applicable
Author

hi Amit..

This is not i want.. I want only on Month Basis.. JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC ..

say i have a List Box for Month.. if i select MAR...I GET Value for MAR And FEB

amit_saini
Master III
Master III

Hi,

Try this:

=Date(MonthStart(Max(DateField), -1), 'MMM')

Thanks,

AS

pradnyat
Creator
Creator

Hi,

Try below expression, hope this will solve your issue

=Date((Datefield)-1,'MMM-YY')

jonathandienst
Partner - Champion III
Partner - Champion III

The simplest way to perform this sort of analysis is to have a month sequence number in the master calendar

     Calendar:

     LOAD ....

          Date,

          Year(Date) As Year,

          Month(Date) As Month,

          Year(Date) * 12 + Month(Date) As MonthSeq,

          ...

Now you can use the expressions for selected month and the previous month:

     Sum({<MonthSeq = {"$(=Max(MonthSeq))"}>} Sales)

     Sum({<MonthSeq = {"$(=Max(MonthSeq) - 1)"}>} Sales)


You may need to override selections of Month and Year....

     Sum({<MonthSeq = {"$(=Max(MonthSeq))"}, Month, Year>} Sales)

     Sum({<MonthSeq = {"$(=Max(MonthSeq) - 1)"}, Month, Year>} Sales)


See

Understanding the Master Calendar (video)

Calculating rolling n-period totals, averages or other aggregations


Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thanks Amit,

Its Working Fine.. But When i select JAN2015 its Shows the Value for DEC2015.. Can we show DEC2015 Value..

Thanks Once Again

senpradip007
Specialist III
Specialist III

PFA. Hope it is you are looking for.

timanshu
Creator III
Creator III

You need to have date field also. Create it if does not exist in model.

In Script add , Date(makedate(Year,month),'MMYYYY') as Date.

then

Sum({<Date= {'<=$(=max(Date))>=$(=Date(addmonths(Date,-1),'MMYYYY'))'}>}Sales).

Not applicable
Author

i m trying this Way for Previous Month..

=if(Month= 'Jan',sum({<Month = {$(vPreviousMonth)}, Year =(Max(Year)-1)>}Price_Pcs_Incl_Discount),sum({<Month = {$(vPreviousMonth)}>}Price_Pcs_Incl_Discount)).. its not showing any thing..