Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
bharatkishore
Contributor III

Need last Year

Hello All,

I have a month field where the data is like May-16,Jun-16.

Now my requirement is i need to get last year. For example when i select May-16 i should get May-15.

I have given max(month)-12 but it is converting to integer..like 42479..Can you please help me on this..

Thanks,

Bharat

1 Solution

Accepted Solutions
antoniotiman
Honored Contributor III

Re: Need last Year

See attachment

12 Replies
antoniotiman
Honored Contributor III

Re: Need last Year

Hi,

Try

MonthName(AddMonths(Max(Month),-12))

Regards,

Antonio

hrlinder
Honored Contributor

Re: Need last Year

you can use if month is a datefield like May-16 and not only May

addyears(max(month),-1)

bharatkishore
Contributor III

Re: Need last Year

Thanks Antonio for the reply..

I have given the following condition and in vlastyear i have given the following condition =MonthName(AddMonths(Max(S5_Month2),-12))

=sum(if(S5_Month2=vLastYear,S5_Leads))..

But i am getting the values are 0.

agomes1971
Valued Contributor

Re: Need last Year

Hi,

please see this

Current Month v. Same Month Last Year

HTH

André Gomes

antoniotiman
Honored Contributor III

Re: Need last Year

Try

Sum({<S5_Month2={'$(=vLastYear)'}>} S5_Leads)

bharatkishore
Contributor III

Re: Need last Year

I have tried but still the value is 0..

antoniotiman
Honored Contributor III

Re: Need last Year

Instead of

MonthName(AddMonths(Max(Month),-12))

try

Date(AddMonths(Max(Month),-12),'MMM-YY')

bharatkishore
Contributor III

Re: Need last Year

Please find the attached qvw...

When it is without selection it is coming but when i select any month the data is becoming 0..Kindly check..

Not applicable

Re: Need last Year

Use this to get previous year same month

MonthEnd(max(DATEFIELD),-12)

for your requirement   like this   Date(MonthEnd(max(DATEFIELD),-12),'MMM-YY')

Community Browser