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

How to display Last 12 Month in Dimension in Bar Chart

Hi,

In my requirement, I want to show last 12 months data in dimension in dar chart.

EX:

Dimension : Month Year ( Api-2015 )

Expression : Count (Items).

the data is from 3 Years. i Want to show only 12 months dynamically.

any one help on this.

Regards,

Chennaiah

7 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

I would usually use a set filter on the expressions to limit data to the last 12 months, like

          Sum({<Date = {">=$(=AddMonths(Max(Date), -12))"}>} Sales)

See also this article: Simply create YTD, moving totals and comparisons versus Year Ago

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

I have something similar, hope this will help.

On the Dimension limits tab, select Restrict which values are displayed, then in show only, select Largest in the Dropdown, and then 12 in Value.

I used it in a rolling 12 month stacked bar chart, works fine, then you have the calculation in the expression field.

mohammadkhatimi
Partner - Specialist
Partner - Specialist

=sum({1<DATE={'>=$(=MonthStart(Max(Date_field),-12))<=$(=MonthEnd(Max(Date_field),-1))'}>}Sales)

Try above expression

Hope it helps you..

Regards,

Mohammad

Not applicable
Author

Thanks Andret,

But it showing between Api-2014 to Mar-2015, it not showing current month EX May 2015

mohammadkhatimi
Partner - Specialist
Partner - Specialist

Try this:


=sum({1<DATE={'>=$(=MonthStart(Max(Date_field),-12))<=$(=MonthEnd(Max(Date_field)))'}>}Sales)



Not applicable
Author

Strange, are you sure everything is right, do yo have data for April and May 2015, this could give wrong values if you have missing months.  have not picked up this problem myself, mine is working 100%. Maybe check your load order. Check the Sort tab as well, maybe the sorting is wrong. Can you maybe  give a reduced data model with some records for each of the periods?

amit_saini
Master III
Master III

Hi,

See the attachment.

Thanks,
AS