on 09-04-2013 3:30 PM
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
Hi Lynne,
1) I hope you have a Group on the Route field
2) Place the @Gap formula on the Details Section
3) Create this formula and place it on the Details Section as well:
whileprintingrecords;
stringVar MetersWithGaps;
if {@Gap} >= {?Gap Parameter} then
MetersWithGaps := MetersWithGaps + {METERREAD.METER_NUMBER} + ", ";
4) Create this formula and place it on the Group header:
whileprintingrecords;
stringVar MetersWithGaps := "";
5) Another formula on the Group Footer to Display the final Meters:
whileprintingrecords;
stringVar MetersWithGaps;
Left(MetersWithGaps, len(MetersWithGaps)-2);
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.