Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Selecting LAST MONTH

i have some data  in my Qlikview

My filters are Years  and Months

2000 to  2015

and months   Jan to  December

Working Nicely:  When i select  year and Month together  for example:     year 2014 and month july   it will give me the data of  july 2014.

My Requirement     if i click  year  2014  or any previous years  (without selecting month)  it should give me the data of  last month (December)

and If i Select  2015  it should give me the  the data of  Last Month ( in my case May is my last Month)

Please write any set analysis code for me plz

thanks

1 Solution

Accepted Solutions
santhoo_san
Partner - Creator II
Partner - Creator II

Hi Tahir,


Check the Month field. I presume that the Month field has string (ie., Apr, May ....), you can create another filed to identify the month as numeric (i.e, 1,2,3,4,5,6,7,8,9,10,11,12), as Max and min functions does not work on string. Please share a sample app, so that we can have a look.

View solution in original post

12 Replies
qlikmsg4u
Specialist
Specialist

Try this

=Sum({$<Month={$(=Max(Month))}>}Sales)

santhoo_san
Partner - Creator II
Partner - Creator II

Use below expression:

Sum({<Year={$(=Max(Year))}, Month= {"$(=max({<Year={$(=max(Year))}>} Month))"},Month= >}Sales)

daniel_kusiak
Creator II
Creator II

Both will work fine but Sum({$<Month={$(=Max(Month))}>}Sales) is much easier 🙂

Not applicable
Author

thanks santhosh!

let me clear   we have employees   in our  Department

year 2015

employees:

                         Year 2015       JAN     FEB     MAR     APR     MAY

No. of Employees   (???)             285     290      295        287     291

WHEN I SELECT:  YEAR 2015 AND MONTH JAN IT GIVES ME 285
BUT I NEED ... IF I SELECT ONLY  YEAR 2015 ON MY YEAR LIST BOX

RESULT SHOULD BE TAKEN FROM LAST MONTH ( WHICH IS MAY)  EMPLOYEES AT (???) IN MY TABLE

second:   if i click year 2014   the result should be the number of employees in last month( December 2014)

MY EXPRESSION IS  LIKE THIS

=num(Count(distinct{$<Year = {$(=Max(Year))}, Month= {"$(=max({<Year={$(=max(Year))}>} Month))"}, CAL_Month=,[Dept Code]= {'5555'}>} [Employeeid]))

Not applicable
Author

thanks but read my detailed reply in below

it is not working with me

Not applicable
Author

it is not working with me

i have written in above detail in my reply please review it

thanks

santhoo_san
Partner - Creator II
Partner - Creator II

Hi Tahir,


Check the Month field. I presume that the Month field has string (ie., Apr, May ....), you can create another filed to identify the month as numeric (i.e, 1,2,3,4,5,6,7,8,9,10,11,12), as Max and min functions does not work on string. Please share a sample app, so that we can have a look.

MayilVahanan

Hi

Hope you have date field,

=num(Count(distinct{<Date = {">=$(=MonthStart(Max(Date))) <= $(=MonthEnd(Max(Date)))"}, CAL_Month=,[Dept Code]= {'5555'}>} [Employeeid]))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

yes my month field is date field it will take the last day of the month