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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
NavinReddy
Creator II
Creator II

How to get three months

Hi Dear Experts,

I have month column in my fields list.

Here based on Month selections i have to display three Consecutive Months in pivot table

Here is my Month filed Current im using "Month(MonthStart(Date(Mid([MTRC_FCT_DT],1,8)))) as Month"

Any suggestions how to achieve this

Ex:

if Month= Jan (Month-2, Month-1,Month)

    O/P= Nov, Dec,Jan

if Month= Feb (Month-2, Month-1,Month)

    O/P= Dec,Jan, Feb

if Month= Mar, (Month-2, Month-1,Month)

    O/P= Jan, Feb,Mar

Best Regards,

Niranjan

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Create a variable vMonth: =if(len(GetCurrentSelections()),max(MonthYear),MonthStart(Today()))

Change the expression to =Count({<Month=, MonthYear={">=$(=date(MonthStart($(vMonth),-2),'MMM YY'))<=$(=Date($(vMonth),'MMM YY'))"}>}RAG_RATING_CD)


talk is cheap, supply exceeds demand

View solution in original post

13 Replies
sunny_talwar

You can either use set analysis or use the concept of As-of Table: The As-Of Table

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Won't work if you only have the month numbers. 1 - 2 = -1 and not 12. So you need a date field like Date(MonthStart(Date(Mid([MTRC_FCT_DT],1,8))),'MMM YY') as MonthYear. Then you can select the 3-month period in your chart expressions. For example sum(Amount) would become sum({<Month=, MonthYear={">=$(=MonthStart(max(MonthYear),-2))<=$(=max(MonthYear))"}>}Amount)


talk is cheap, supply exceeds demand
NavinReddy
Creator II
Creator II
Author

Hi Gysbert,

Thanks for your reply

=Count({<Month=, MonthYear={">=$(=MonthStart(max(MonthYear),-2))<=$(=max(MonthYear))"}>}RATING_CB)

with this expression i got the below result, can't we restrict to display only three months data

any suggestions

Best Regards,

Niranjan

Digvijay_Singh

Pl Chk the value of set expression in the header of expression column, smthg might be wrong else expression shouldn't show more than 3 months.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

That result make no sense at all. Can you post a small qlikview document that demonstrates the problem?


talk is cheap, supply exceeds demand
NavinReddy
Creator II
Creator II
Author

Hi Gysbert,

Sorry for my late reply, i have attached sample document

Here based on month selections in pivot i have to display 3months of data

Ex:

if Month= Jan (Month-2, Month-1,Month)

    O/P= Nov, Dec,Jan

Best Regards,

Niranjan

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try this expression:

=Count({<Month=, MonthYear={">=$(=date(MonthStart(max(MonthYear),-2),'MMM YY'))<=$(=Date(max(MonthYear),'MMM YY'))"}>}RAG_RATING_CD)


talk is cheap, supply exceeds demand
NavinReddy
Creator II
Creator II
Author

Hi Gysbert,

its working fine, But if can i clear the filters chart its not displaying any data

how can i make it current month as default selection

Best Regards,

Niranjan

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Create a variable vMonth: =if(len(GetCurrentSelections()),max(MonthYear),MonthStart(Today()))

Change the expression to =Count({<Month=, MonthYear={">=$(=date(MonthStart($(vMonth),-2),'MMM YY'))<=$(=Date($(vMonth),'MMM YY'))"}>}RAG_RATING_CD)


talk is cheap, supply exceeds demand