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

Announcements
Discover the Trends Shaping AI in 2026: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Previous two months count

Hello All,

     I need two show Previous 2 months count in my chart like Apr'14,May'14,June'14 where currently i can show count for June'14 how to show count for Apr'14 and May'14?? and dynamic if current selection is May'14 then it should show Mar'14 Apr'14 May'14?

3 Replies
senpradip007
Specialist III
Specialist III

Count({<Date={">=$(=AddMonths(Max(Date))) <=$(=Date(Max(Date),'DD/MM/YYYY')) "} >} Field)

Assume that the date format is as DD/MM/YYYY.

Sokkorn
Master
Master

Hi Rohit,

In your calendar table, add new field for month flage. Ex:

[Calenda]:

Load

     Dates,

     Months,

     ...

     Years*12+Month     AS [MonthFlage]

FROM....

Then in expression, we can use

Count({$<[MonthFlage]= {">=$(=Max([MonthFlage])-2)<$(=Max([MonthFlage]))"} >} Field)

It would be great if you can provide your sample app.

Regards,

Sokkorn

Not applicable
Author

Try this:

Current Month:


=count({< CalendarYear=, CalendarMonth=,  CalendarDate={'>=$(=MonthStart(Max(CalendarDate)))<=$(=MonthEnd(Max(CalendarDate)))'}  Field)

Last Month (i.e Current Month-1):-

=count({< CalendarYear=, CalendarMonth=,  CalendarDate={'>=$(=MonthStart(Max(CalendarDate), -1))<=$(=MonthEnd(Max(CalendarDate), -1))'}  Field)

Current Month-2:-


=count({< CalendarYear=, CalendarMonth=,  CalendarDate={'>=$(=MonthStart(Max(CalendarDate), -2))<=$(=MonthEnd(Max(CalendarDate), -2))'}  Field)