Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculate Max month as a dimension?

Hi All,

Actually i have 8 months, in this 7 months comes under 2013 and 1 month comes under 2014. so here max month should be 1st month

of 2014.How should i calculate max month as a dimension?.i used autonumber function on month&year but 1st month of 2014 giving 1 number so i am getting dec-2013 as a max month.i need jan-2014 as a max month.

plz help me on this.

Thanks,

Ashok.

1 Solution

Accepted Solutions
Not applicable
Author

Try below expression.

=MonthName(Max(datefield))  //returns like Jan 2014

=Month(Max(datefield))   // returns like Jan

Regards,

Kabilan K.

View solution in original post

7 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Define month as concatenation of year and mont i.e. 201307, 201308 ... 201401, the sorting is automatic in this way and even the max

Hope it helps

datanibbler
Champion
Champion

Hi Ashok,

instead of using the month such as it is, calculate MONTHEND() - that will give you Jan-31-2014 for this January, which should be your max_month, yes? Then calculate the max date out of these and then just plug in a MONTH() function.

Not applicable
Author

Try below expression.

=MonthName(Max(datefield))  //returns like Jan 2014

=Month(Max(datefield))   // returns like Jan

Regards,

Kabilan K.

jvishnuram
Partner - Creator III
Partner - Creator III

Hi Ashok,

You can also use the MONTHID's instead of Month names like Max({$<MonthID={"$(=Max(MonthID))"}>}Month).

Not applicable
Author

Hi,

You can use calculated dimension as MonthName(Max(field)).

HTH

-shruti

sudeepkm
Specialist III
Specialist III

I think you can use a Month Number. Suppose your date field name is Period then you can use the below expression in your Load Script to create a Month Number

num(Month(Period)) + if(Year(Period)=Year(Today()),12,0) as MonthNum,

and then you can use it in your chart expressions. Max(MonthNum)

Not applicable
Author

Thanks kabilan it working fine.