Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
azmeerrehan
Partner - Creator
Partner - Creator

Adding Months

In my current data set  I have a date field 'YYYYMM' . The data I have is a MTD (MOnth to date data). So by default I would like to show the cumulative (YTD)  for Current year and previous year for comparison. 

I have created a variable called vMonthToday = Month(Today()).


I have tried the below expression and its not working .

sum({$<CalendarYear = {$(=Max(CalendarYear)-1),$(=Max(CalendarYear))},CalendarMonthName={"<=$(=vMonthToday)"}>}  Sales).

Desired result

So for example we are in June  so I would like to see

2017 /$65896... (Cumulative for Jan Thru Jun for 2017)

2016/ $75365...(Cumulative for Jan Thru Jun for 2016)

Can some one please help

1 Solution

Accepted Solutions
antoniotiman
Master III
Master III

Hi Rehan,

see attachment.

Regards,

Antonio.

View solution in original post

9 Replies
vishsaggi
Champion III
Champion III

May be this?

sum({$<CalendarYear = { ">= $(=Max(CalendarYear)-1) <= $(=Max(CalendarYear))" },

            CalendarMonthName = {"<=$(=vMonthToday)"}>}  Sales)

azmeerrehan
Partner - Creator
Partner - Creator
Author

Sorry doesn't work

vishsaggi
Champion III
Champion III

Can you share a sample file to look into ?

azmeerrehan
Partner - Creator
Partner - Creator
Author

how do I attach a file now. I dont get an  option the Reply message??

azmeerrehan
Partner - Creator
Partner - Creator
Author

Attached are the sample files

azmeerrehan
Partner - Creator
Partner - Creator
Author

Just added the sample xls and qvw

antoniotiman
Master III
Master III

Hi Rehan,

see attachment.

Regards,

Antonio.

MK_QSL
MVP
MVP

Are you sure you are looking for below based on the data you have provided?

2017 /$65896... (Cumulative for Jan Thru Jun for 2017)

2016/ $75365...(Cumulative for Jan Thru Jun for 2016)

MK_QSL
MVP
MVP

Use this script

Data:

Load

  Year,

  Month,

  num(month(Date#(Month,'MMM'))) as MonthNumber,

  Sales

FROM

https://community.qlik.com/servlet/JiveServlet/download/1294277-284479/Sample.xlsx

(ooxml, embedded labels, table is Sheet1);

Now use as below

Dimension

Year

Expression

=SUM({<MonthNumber = {"<=$(=Num(Month(Today())))"}>}Sales)