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

Count of Current Month vs Previous Month

Hi All,

I have the following data:

CodeDate(MM/DD/YYYY)
ABC1/19/2014
DEF2/15/2014
XYZ2/20/2014
HIJ3/25/2014
PQR3/27/2014
RST3/30/2014

I need to find the Count of Code for March v/s Feb.

I used the following variables:

vCurrentMonth =MonthName(Today())

vPreviousMonth = Date#((vCurrentMonth -1),'MMM-YYYY')

I am unable to find the count of Code for the above data.

1 Solution

Accepted Solutions
Not applicable
Author

Try using calculated dimension in pivot table like

=if(MIxMatch(MONTH(SALEDATE),month(today()),month(monthstart(today())-1)),MONTH(SALEDATE))

and the Expression = Count(CODE)

View solution in original post

8 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Try this set of expression

Count({<DateField={">=$(=MonthStart(Today()))<=$(=Today())"}>} Code) for Current month count

Count({<DateField={">=$(=MonthStart(Today(), -1))<=$(=Date(Floor(MonthEnd(Today(), -1))))"}>} Code) for Previous month count.

tresesco
MVP
MVP

Try like:

vPreviousMonth = MonthName(AddMonths($(vCurrentMonth), -1))

MK_QSL
MVP
MVP

Please check enclosed file...

Not applicable
Author

Hi,

I did get my Current Month and Current Month -1 answer correct, however I would like to know can I get CurrenMonth and CurrentMonth-1 field as dimension.

As I want to develop a chart for this two dimensions only.

tresesco
MVP
MVP

Two ways:

  • Calculate one additional column as PreMonth in the script.
  • Synthetic dimension using ValueList() in the front end.
MK_QSL
MVP
MVP

Create a straight table with

Month as dimension and

Expressions as below...

For Current Month

Label

=Month(Today())

Expression =

COUNT({<Month = {'$(=Month(Today()))'}>}Code)

For Previous Month

Label

=SubField('$(MonthNames)',';',Month(Today())-1)

Expression

COUNT({<Month = {"$(=SubField('$(MonthNames)',';',Month(Today())-1))"}>}Code)

Not applicable
Author

Try using calculated dimension in pivot table like

=if(MIxMatch(MONTH(SALEDATE),month(today()),month(monthstart(today())-1)),MONTH(SALEDATE))

and the Expression = Count(CODE)

jagan
Luminary Alumni
Luminary Alumni

Hi Hitesh,

Please find attached file for solution.

Regards,

Jagan.