Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

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

How to find last 3, 6, 12 months ???

Hi in my script i need to include a field such as month values ,which should hold the last 3months , last6months, last 12 moths(3 colums).. When i click last 3 months the calculation should change.. I need it in script

For example i have used the below script for finding QTR1, 2, 3, 4 , simillarly i want for last3 months , 6 , 12 months

If(Num(month([Session Start]))<=3, 'Q1-' & Year([Session Start]),

If(Num(month([Session Start]))<=6, 'Q2-' & Year([Session Start]),

  If(Num(month([Session Start]))<=9, 'Q3-' & Year([Session Start]),

   If(Num(month([Session Start]))<=12, 'Q4-' & Year([Session Start])

    )

     )

      )

       ) as Qtr,

1 Reply
jagan
Not applicable

Re: How to find last 3, 6, 12 months ???

Hi,

Use the following expression

For last 3 Months:

=Sum({<DateField={'>=$(=MonthStart(Max(DateField), -2))<=$(=MonthEnd(Max(DateField)))'}>} Sales)

For last 6 Months:

=Sum({<DateField={'>=$(=MonthStart(Max(DateField), -5))<=$(=MonthEnd(Max(DateField)))'}>} Sales)

For last 12 Months:

=Sum({<DateField={'>=$(=MonthStart(Max(DateField), -11))<=$(=MonthEnd(Max(DateField)))'}>} Sales)

Regards,

Jagan.