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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Current Year and Previous Year Calculation in one Expression

Hi,

I want to calculate current year and previous year in one expression. Bascially:

if I have MonthYear as Sept 2013 then:

for Current year: it should start from July 2013-Sept 2013

for Previous year: it should start from July 2012-Sept 2012

I am using this formula it gives correct value for current year but for previous year it calculates the whole year (July 2012-June 2013). I want it to stop at Sept 2012.

=Sum({<CalMonthYear=,Date={">=$(=Date(Yearstart(Max(Date),-1,7),'MM/DD/YYYY'))<=$(=Max(Date))"}>}Cases)

Any help?

Thanks.

1 Reply
MK_QSL
MVP
MVP

For Current Year

SUM({<MonthYear = {">=$(=Date(AddMonths(MonthYear,-2),'MMM YYYY')) <=$(=Date(MonthYear,'MMM YYYY'))"}>}SALE)

For Previous Year

SUM({<MonthYear = {">=$(=Date(AddMonths(AddYears(MonthYear,-1),-2),'MMM YYYY')) <=$(=Date(AddYears(MonthYear,-1),'MMM YYYY'))"}>}SALE)

Change appropriate field name as per your data model..

i.e. SALE to Cases, MonthYear to CalMonthYear