Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Referring to Current month, previous month, and the month before

Hey guys,

I had a doubt which i hope you guys will be able to solve for me.

I refer to the current month name in my text code as : =Monthname(max(MonthName))   >> This returns April as value.

The previous month is referred to as : =Monthname(max(MonthName)-1)  >> This returns March as value.

However, i want to display the month name before that (to show data for 3 months). So using the same analogy I tried =Monthname(max(MonthName)-2). ------ But for some reason it still returns the month name - March------

Could someone tell me where i'm going wrong? Thanks a ton! 😃

- Justin

2 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Try this.

     =monthname(addmonths(max(Date),-1))

     Use the Date field instead of monthname.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

=MonthName(AddMonths(Max(DateFieldName)))      //To get current / max month name

=MonthName(AddMonths(Max(DateFieldName), -1)) 

//To get previous month name

=MonthName(AddMonths(Max(DateFieldName), -2))  //To get second previous month name

If you want to display data for all the 3 months like count/sum then use like this

=Sum({<DateFieldName={'>=$(=MonthStart(Max(Date), -2))<=$(=Max(DateFieldName))'}>} Sales)

Hope this helps you.

Regards,

Jagan.