Skip to Content
0
Former Member
Sep 04, 2013 at 02:30 PM

Creating a customized summary for a group

19 Views

I'm trying to create a customized summary for a group. Instead of doing something like summing records in a group, I'd like to concatenate records in a group that satisfy a given condition. (If this is too complicate, I could first create a formula that executes the condition by recording the value if the condition is met and "" if it isn't.) I figure I need a loop to execute this but I can't seem to figure out how to tell the formula to proceed to the next record in the group. Please look at my code below:

Local stringVar MetersWithGaps := "";
Local numberVar i := 1;
Local numberVar LastMeter := maximum ({METERREAD.SEQUENCE_NUMBER});

for i := 1 to LastMeter step 1 do
(
if {@Gap} >= {?Gap Parameter} then MetersWithGaps := MetersWithGaps + {METERREAD.METER_NUMBER} + ", ";
);
MetersWithGaps

Basically, I want to look at the time gap between reading each meter in a route (from sequence number one to max). If the gap (@Gap is a formula that calculates the gap for each meter) is greater than the specified duration (?Gap Parameter), please concatenate the meter number to a string called MetersWithGaps.

For the below example, given ?Gap Parameter = 1.5 minutes, you should get:

Route MetersWithGaps A A2, A3 B B2

Route Meter Gap A A1 1 A A2 2 A A3 2 B B1 1 B B2 2 B B3 1

Please help me figure out the error in my formula. Thanks, Lynne