Help Creating Array in Crystal Report 2011

Hi Crystal Array Experts,

I defined Array in my report to calculate one field- 6 months data. The below are arrays which I defined in my report to calculate 6 months
formula.

  1. first I initialized array with this formula:

whileprintingrecords;
Shared Numbervar Array CashTotalArray;
Redim Preserve CashTotalArray[1000];
Shared Numbervar CashTotalCounter:=1;

  1. Then I created second formula to update/calculate sum ({@fCashTotalArray-2 Update):

whileprintingrecords;
Shared Numbervar Array CashTotalArray;
Redim Preserve CashTotalArray[1000];
Shared Numbervar CashTotalCounter;

CashTotalArray[CashTotalCounter]:=Sum({@Cash_total}{@Month_PostDate}, “monthly”);
CashTotalCounter:=CashTotalCounter+1;
Sum({@Cash_total}, {@Month_PostDate}, “monthly”)

  1. Then I created third formula for 6 months sum (for 6-months sum)

EvaluateAfter({@fCashTotalArray-2 Update});
Shared Numbervar Array CashTotalArray;
Shared Numbervar Counter;
Shared Numbervar MonthCounter;

if MonthCounter>=6

then Sum(CashTotalArray[(MonthCounter-5) to MonthCounter])
else 0

As I used MonthCounter here so I created two new formula to initialize and update Monthcounter.

  1. To initiate Monthcounter: Shared Numbervar MonthCounter:=1;

  2. To update Monthcounter:
    Shared Numbervar MonthCounter;
    MonthCounter:=MonthCounter+1;

After all this, If I put third formula( for 6 months sum) in report, it gives me zero (0) values. Can someone who worked with Arrays tell me, where am I wrong. Why my third formula is giving me zero values while it should give me last 5 months+current month data.

Thanks in advance,

Remi


rparauha (BOB member since 2013-12-24)