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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
matthewp
Creator III
Creator III

Expression calculation for last 12 months not including this month

I'm trying to create an expression calculation for last 12 months not including this month.

So for February it would be 2016 FEB to 2017 JAN

I tried

=Count({1<MMMYY ={'>=$(=Date(AddMonths(Today(), -13),'MMM-YY'))<=$(=Date(Today(), 'MMM-YY'))'}>} DISTINCT [MYID])/12

But it didn't work.

21 Replies
matthewp
Creator III
Creator III
Author

that gives an error

matthewp
Creator III
Creator III
Author

No, that is for a trigger, i was just sharing that to show what format my date column is in

sdmech81
Specialist
Specialist

By mistake I put = aftr num..

Replace it with ( n try..Plss attach file if possible..

Sachin

matthewp
Creator III
Creator III
Author

still an error

Anonymous
Not applicable

Hi Matthew ,

Can  you share some sample Application.

Regards

Vinod

sunny_talwar

Try this:

=Count({1<MMMYY ={"$(='>=' & Date(AddMonths(MonthStart(Today()), -12), 'YYYYMM') & '<=' & Date(AddMonths(MonthStart(Today()),-0), 'YYYYMM'))"}>} DISTINCT [MYID])/12

sunny_talwar

I think the issue was that we were using single quotes around the date format and we had another set of single quotes around our set modifier. That won't work. I changed the outside single quotes to double quotes now. Hopefully it should work now

matthewp
Creator III
Creator III
Author

Still 0

sunny_talwar

Do you have data in your application for Feb 2016 to Jan 2017?

matthewp
Creator III
Creator III
Author

Resolved this by doing the expression as:

=ROUND(COUNT({<[MYDATEFIELD]={'$(last12notinccur)'}>} DISTINCT MYID)/12)

and the variable "last12notinccur":

=  '>=' & date(AddMonths(MonthStart(Today()),-12), 'YYYYMM')   & '<=' & date(AddMonths(MonthStart(Today()),-1), 'YYYYMM')