Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Rehan
Creator III
Creator III

Generating last 24 MOnths from today

I need to show the last 24 months data. I have defined a variable below  and doing a loop

Let vLookbackLength = (month(today()))+24;

For i = -$(vLookbackLength) to -1

But its not giving me  the right number of months . What Am I missing here ?

 

1 Reply
Vegar
MVP
MVP

vLookbackLength = (month(today()))+24;

For i = -$(vLookbackLength) to -1
Trace $(i);
Next i
Will trace -27 to -1 as Month(today()) =3 (March).

Try this instead
For j = 0 to 24 //or 23 depending on if you include current month as one of the 24 months
Let vPeriod = MonthName(today()-$(j));
Trace $(vPeriod);
Next

It should trace all moths from the current to February 2018.