Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
dseelam
Creator II
Creator II

Rolling Past 12 Months

Hello Every One

The below statement working perfectly alright but does the past 12 months will be changing daily once the script is reloaded ?

   Let vMin = num(Makedate(2011,01,01));

   Let vMax = num(today());

   Temp:

    Load

      Date($(vMin) + Iterno() -1) as Date

    Autogenerate 1

    While Date($(vMin)) + Iterno() -1 <= $(vMax);

    MasterCal:

    Load Date,

    Month(Date) as month,

    Year(Date) as Year

    Resident Temp;

    Drop table Temp;

1 Solution

Accepted Solutions
Not applicable

Hey Dinesh,

Rolling past 12 months will always be changing as time progresses.

Say today past 12 months will be Jan 2013 - Jan 2014

When you are in Feb it should be Feb 2013 - Feb 2014

If you want to do that you can change vMin

Let vMin =  num( Addmonths(Today(),-12)) ;


Hope it helps

Thanks

AJ

View solution in original post

5 Replies
Not applicable

Hey Dinesh,

Rolling past 12 months will always be changing as time progresses.

Say today past 12 months will be Jan 2013 - Jan 2014

When you are in Feb it should be Feb 2013 - Feb 2014

If you want to do that you can change vMin

Let vMin =  num( Addmonths(Today(),-12)) ;


Hope it helps

Thanks

AJ

dseelam
Creator II
Creator II
Author

Hope it will change every day instead of every month

aveeeeeee7en
Specialist III
Specialist III

Hi Dinesh

In the Script create this Field:

if(TempDate>=monthstart(AddMonths($(vToday), -12)) AND TempDate<monthstart($(vToday)), 1, 0) as Rolling12MthFlag

Create an variable vToday which has value of your Today Date or your Table's Max Date as per your requirement.

After creating the Above field in your Script now create a Chart.

eg. Line Chart - Your Dimension would be  : Month_Year Field

                       Your Expression would be : sum({$ <Rolling12MthFlag={1}>} SalesAmount)

  

Hope this works for you.

Regards

Aviral Nag

Not applicable

Sorry should have explained better. It will change everyday as we are subtracting 12 months from today.

so today it will be   01/24/2013 to 01/24/2014 and

tomorrow   01/25/2013 to 01/25/2014  and so on as long as the app gets reloaded daily.

Thanks

AJ

Not applicable

Use MonthStart function if you need to reset the value to 1st of month