Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
juagarti
Contributor III
Contributor III

Range of month in a bar chart

Hello,

I'm trying to make a bar chart to show the sales . First I'm trying to show the sales in the year, the dimension are the month ( from jan. to dec.). Now I'm trying to show the sales from jun. of the previous year (2014) to jun of the actually year (2015)

How can I do this?

thank very much!!

5 Replies
Anonymous
Not applicable

at script create a numeric field, say MonthNumber like this:

YearField*12+month(DateField) as MonthNumber

then take Month as a Dim

and expression would be:  sum({<MonthNumber={'>=$(=max(MonthNumber)-12)<=$(=max(MonthNumber)'} >} Sales)

juagarti
Contributor III
Contributor III
Author

I use the expresion

=sum({<fecha={">=$(=date(addmonths(monthstart(today()),-18),'DD/MM/YYYY'))<=date(monthstart(today()),'DD/MM/YYYY')"}>}Ventas)

And the chart show the data between june of 2014 to december of 2015 this is ok. The problem is that I'm create in the script a new two fields using fecha field (DD/MM/YYYY), year(fecha) and month(fecha) .

I need that when I select year 2015 for example, the chart show me dates between june of 2014 and december of 2015.

and for another example, when I select year 2014 the chart show me dates between june of 2013 and december of 2014.

Now when I select year 2015 the chart show me only data of 2015 and not from june of 2014 to december of 2015.

Can you help me?

thanks!

thakkarrahul01
Creator
Creator

If you have AS of data in your system then you can extend solution suggested by balrajahlawat‌ by storing month number in variable. Variables will contain latest month number and it will get updated on selection will indeed will give you moving 12 months in chart.

thakkarrahul01
Creator
Creator

Hi Juan,

Please create a variable storing a latest year month value and use that variable inside your set analysis condition to provide range.

For example VCurrentMonth stores your month than give range between VCurrentmonth & VCurrentmonth -12.

Please be mindful that variable should get updated on selection of month year dimension.