9 Replies Latest reply: Aug 25, 2015 2:59 PM by vinoth govindarajan

# Loop Counter Value Calculation

Hi,

I am trying to creating a new calendar which associates next three months dates for a current month.

Ex: Aug month associated to Sep,Oct and Nov dates similarly Sep associated to Oct,Nov and Dec dates and so on.

For creating this, the loop counter value should be sum of number of days in next three months as per my understanding.

so how to calculate the "sum of number of days in next three months"  in the while statement.

i.e while iterno()<= Calculation condition.

Regards,

VR

• ###### Re: Loop Counter Value Calculation

Try with this expression

• ###### Re: Loop Counter Value Calculation

Thank you Alessandro.

• ###### Re: Loop Counter Value Calculation

I think you might be able to do this using AddMonths to create Min and Max Dates and then use IntervalMatch to get what you are looking for.

• ###### Re: Loop Counter Value Calculation

Have a look at the following script:

Table:

MonthYear;

MonthYear

Jan-2015

Feb-2015

Mar-2015

Apr-2015

May-2015

Jun-2015

Jul-2015

Aug-2015

Sep-2015

Oct-2015

Nov-2015

Dec-2015

];

Temp:

max(End) as maxDate

Resident Table;

Let varMinDate = Num(Peek('minDate', 0, 'Temp'));

Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));

DROP Table Temp;

TempCalendar:

LOAD Date(\$(varMinDate) + IterNo() - 1) as Date

AutoGenerate 1

While \$(varMinDate) + IterNo() -1 <= \$(varMaxDate);

Left Join (Table)

IntervalMatch (Date)

End

Resident Table;

• ###### Re: Loop Counter Value Calculation

Thank you Sunny.

• ###### Re: Loop Counter Value Calculation

Why are you trying this? You might be able to compare 4 consecutive months using a set expression instead of some special calendar fields.

Regards

Marco

• ###### Re: Loop Counter Value Calculation

Hi Marco,

I just wanted to implement this in the script level instead of using set expression.

• ###### Re: Loop Counter Value Calculation

Try like Below:

While IterNo() <= AddMonths(MonthStart(Today()),3) - Today() + 1;

• ###### Re: Loop Counter Value Calculation

Thank you dathu.