I started by creating pass-in fields "Seg1," "Seg2," "Seg3," ... as well as "BestSeg." Then I used this script to set the values:
[% Begin Unverified Perl
my $row1 = GETVALUE('S1_r1');
my $row2 = GETVALUE('S1_r2');
my $row3 = GETVALUE('S1_r3');
my $bestSeg = 0;
my $bestScore = 0;
my $seg1 = $row1 * .11 + $row2 * .12 + $row3 * .13;
SETVALUE('Seg1', $seg1);
if ($seg1 > $bestScore) {
$bestSeg = 1;
$bestScore = $seg1;
}
my $seg2 = $row1 * .21 + $row2 * .22 + $row3 * .23;
SETVALUE('Seg2', $seg2);
if ($seg2 > $bestScore) {
$bestSeg = 2;
$bestScore = $seg2;
}
my $seg3 = $row1 * .31 + $row2 * .32 + $row3 * .33;
SETVALUE('Seg3', $seg3);
if ($seg3 > $bestScore) {
$bestSeg = 3;
$bestScore = $seg3;
}
SETVALUE('BestSeg', $bestSeg);
End Unverified %]
My code is set up for three rows, but it should be fairly simple to expand it to satisfy your number of segments.
Your calculations don't sound like they're going to take a lot of time, but you can test the performance for yourself.