I have a report that I'm trying to modify to remove a Record Selection so the report will display all events in the date range, but apply the same filter within an array so it only calculates only events that have the filter that I'm removing in the Record Selection.
So, in the Record Selection I have the following:
and {OBI_EquipmentMaster.EquipmentType}=3
Which limits the report to only drives (events) in which a promotion is assigned. Promotions being Equipment Type = 3.
But I would like to remove this and place this filter in the Array formula instead so only Promotions are calculated in Cross-Tab.
In my array builder, the following formula was used:
whileprintingrecords;
stringvar d:= {OBI_EquipmentMaster.Description};
numbervar p:= {DriveProjectionAndCollectedTotals.ProcedureProjection};
numbervar pe:= {DriveProjectionAndCollectedTotals.ProceduresPerformed};
//numbervar et:= {OBI_EquipmentMaster.EquipmentType};
stringvar array ad;
numbervar array ap;
numbervar array ape;
numbervar c2:= 1;
numbervar n:=0;
// check to see if the description has been added to the string array
// if not, add it plus add the initial projection value to the number arrays
if not (d in ad) then
// tried to add filter for only certain equipment type - assigned to variable above
//if not (d in ad) and et=3 then
(
numbervar c:= c + 1;
redim preserve ad[c]; ad[c]:= d;
redim preserve ap[c]; ap[c]:= p;
redim preserve ape[c]; ape[c]:= pe;
)
else
// if the description is already in the array, find its position
// then add the new projection as a running total to the appropriate number array values
(
while c2 <= count(ad) do
(
if d = ad[c2] then (n := c2; exit while);
c2 := c2 + 1
);
ap[n]:= ap[n] + p;
ape[n]:= ape[n] + pe;
);
// grand running totals
numbervar gp:= gp + p;
numbervar gpe:= gpe + pe;
My modification of the array included adding another variable for equipment type:
numbervar et:= {OBI_EquipmentMaster.EquipmentType};
And adding a line in the If statement:
if not (d in ad) and *et=3* then
The formula checks out fine, but when I try to run the report I get an error indicating:
A subscript must be between 1 and the size of the array.
ap[n]:= *ap[n]* + p;
Specifically, the ap[n] it does not seem to like.
Any suggestions on how to remedy this?