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

Current Month & Previous Month

Having some issues getting the Previous Month.  I have tried these as Variables and Expressions.

creating  a MONTH column from another field Incident Created Timestamp.
      date(MonthStart([Incident Created Timestamp]), 'MM-YYYY') as Month,

Current Month

=Max(Month) returns 01 - 2016

Previous Month

=Max(Month) -1 returns 42369

=Max(Month-1) returns 42369

=Max((Month) -1, 'MM-YYYY') returns 42369

=Max((Month -1), 'MM-YYYY') returns 42369

=Max(Month -1, 'MM-YYYY') returns 42369

8 Replies
sunny_talwar

Try using AddMonths() function:

=AddMonths(Max(Month), -1)

Anonymous
Not applicable
Author

Sunny T,

That got me closer (12/01/2015).  Is there a way to get it in "MM-YYYY" format?

Then the next step I need is to COUNT the [Incident Identifier] based on the Variables that I created:
vCurrentMonth =Max(Month)

vPrevMonth =AddMonths(Max(Month), -1)

This works when I use the exact Previous Month - =Num(Count({<Month={"12-2015"}>}[Incident Identifier]))

This returns 0 - =Num(Count({<Month={"$(vPrevMonth)"}>}[Incident Identifier]))

This returns "error in set modifier ad hoc element list - =Num(Count({<Month={$(vPrevMonth)}>}[Incident Identifier]))


sunny_talwar

May be this for changing the date format.

=Date(AddMonths(Max(Month), -1), 'MM-YYYY')

Anonymous
Not applicable
Author

That worked.

sunny_talwar

Awesome

Anonymous
Not applicable
Author

The next step I need is to COUNT the [Incident Identifier] based on the Variables that I created:

vCurrentMonth =Max(Month)

vPrevMonth =AddMonths(Max(Month), -1)

This works when I use the exact Previous Month - =Num(Count({<Month={"12-2015"}>}[Incident Identifier]))

This returns 0 - =Num(Count({<Month={"$(vPrevMonth)"}>}[Incident Identifier]))

This returns "error in set modifier ad hoc element list - =Num(Count({<Month={$(vPrevMonth)}>}[Incident Identifier]))

sunny_talwar

It is still isn't working?

fcecconi
Partner - Creator III
Partner - Creator III

Dan

Do you use a master calendar in your app?  For me, I prefer to create a master calendar, then have flags for current month, previous, etc.  Then use set analysis to create my measures.

Regards,

Frank