Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
Not applicable

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
Highlighted

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.

Highlighted
MVP
MVP

Try like:

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

Highlighted
MVP
MVP

Please check enclosed file...

Highlighted
Not applicable

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.

Highlighted
MVP
MVP

Two ways:

  • Calculate one additional column as PreMonth in the script.
  • Synthetic dimension using ValueList() in the front end.
Highlighted
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)

Highlighted
Not applicable

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

Highlighted
MVP & Luminary
MVP & Luminary

Hi Hitesh,

Please find attached file for solution.

Regards,

Jagan.