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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Formula for Previous Month Number

Hi,

I am trying to come up with a formula/function that returns a month number that is n months prior to a given month.

My function should have two arguments: monthnum and n

For example:

f(2,2)=12     -> the month two months before Feb. is Dec.

f(4,3)=1       -> the month three months before Apr.. is Jan.

Best,

R

1 Reply
sunny_talwar
MVP
MVP

May be something like this:

Month(AddMonths(MakeDate(Year(Today(), Date#(Month, 'MMM')), -n))

Replace n with the number of months you wish to go back and Month with whichever month you plan to start with