Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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

Re: Calculate Max month as a dimension?

Try below expression.

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

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

Regards,

Kabilan K.

7 Replies

Re: Calculate Max month as a dimension?

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
Esteemed Contributor

Re: Calculate Max month as a dimension?

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

Re: Calculate Max month as a dimension?

Try below expression.

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

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

Regards,

Kabilan K.

jvishnuram
Contributor III

Re: Calculate Max month as a dimension?

Hi Ashok,

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

Not applicable

Re: Calculate Max month as a dimension?

Hi,

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

HTH

-shruti

sudeepkm
Valued Contributor III

Re: Calculate Max month as a dimension?

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

Re: Calculate Max month as a dimension?

Thanks kabilan it working fine.