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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
dmohanty
Partner - Specialist
Partner - Specialist

Line Graph - Selected Month and Previous 2 Months

Hi All,

I have to show the Last 3 Months Sales data in a Line Graph. The functionality should be like this - If any Month is selected from the List Box, the graph should show - Sales for selected month and its previous 2 months.

Ex: If I select Dec-14, the graph would Sales for Dec-14, Nov-14 and Oct-14

When nothing is selected,  it would show the Latest Month (Feb-15) and previous 2 months (Jan-15, Dec-14).

Could some please help with a demo. Here is the data:

MonthSales
Mar-14100
Apr-14150
May-14120
Jun-14240
Jul-1480
Aug-14180
Sep-14110
Oct-14230
Nov-14330
Dec-14190
Jan-15250
Feb-15280
4 Replies
dmohanty
Partner - Specialist
Partner - Specialist
Author

Any help here please?

danieloberbilli
Specialist II
Specialist II

Please find an example attached.

You should have a master calendar where you can have a consecutive number for your month so that you can easily calculate max(month_number)-1 , -2 ...and so on

!

ramoncova06
Partner - Specialist III
Partner - Specialist III

is your month a string format ? or a date formatted to as 'MMM-YY' if it is a date format you could use the following expression

sum({<Month = {">=$(=(max(Month,3)))<=$(=(max(Month)))"}}Sales)

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

Script:

LOAD

*,

Date(Date#(Month, 'MMM-YY')) AS Date

FROM DataSource;

Now in chart try like this

Dimension: Month

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

Hope this helps you.

Regards,

Jagan.