Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Everyone,
Can anybody tell me how to use expressions as inputs for "for" loop? For example, I used
for i=num(Addmonths(MaxDate,-12,1)) to num(MaxDate)
------
------
Next i;
which doesn't seem to be working. I also tried using variables like
Let A=num(AddMonths(MaxDate,-12,1));
for i=$(A) to num(MaxDate)
------
------
Next i;
Even the 'Let' function is returning the Null value. Any suggestion would be helpful. Thanks in advance.
What is MaxDate? A variable or field?
If it's a numeric variable:
Let A=num(AddMonths($(MaxDate),-12,1));
If it's a field, I believe that won't work.
Hi Swuehl,
Thanks for the quick reply,
MaxDate is a field. The actual task I am trying to achieve is Rolling 12 Months data extraction. I am successful in achieving it in UI using set expressions in straight table as follows,
aggr(SUM({<Year =, Month =, Quarter =, Week =, YearMonth = {">=$(=Date(AddMonths(Max(YearMonth),-12),'YYYYMM'))<=$(=Max(YearMonth))"}>}Current12M),Key),
Here, Key, YearMonth,Current12M are all fields with current12m being the quantity.
Can you help me in using the above set expression in script? I know the set expressions will not work in script, so any suggestions on how to use the same .
Take MaxDate Max(Date) from your Source table then convert it into
Let A= Peek(MaxDate);
Let B=num(AddMonths($(MaxDate),-12,1));
use these variables in the above Script
Regards
John
Hi,
Check the below attachment. Let me know whether this is fine.