gridviewcrystal-reportscrosstabcrystal-reports-formulas

Crystal Reports: Cross-Tab calculating embedded summary comparing multiple cell values


Working with Crystal Reports' GridView object and trying to find a way to compare GridValues amongst a row of values and am having a very difficult time.

Here is the code I am working with in an embedded summary (located directly under the red boxes)...

local numbervar c;
local numbervar r;
local Numbervar cs:=GridValueAt(CurrentRowIndex,CurrentColumnIndex,CurrentSummaryIndex-1);
local numbervar MOST;

if GetColumnGroupIndexOf(1)=2 THEN
(
    for c:=0 to GetNumColumns-2 do    
    (   
        if cs >= GridValueAt(CurrentRowIndex,c,CurrentSummaryIndex-1) then MOST:=cs
        else MOST:=0;
    );
);
MOST;

The problem is that the first Group isn't being looked at (I think...) I kind of fumbled my way to this point, so any advice is greatly appreciated.

hopefully this question is clear enough... but what I am trying to accomplish is setting the color to red for the gridvalue that is the most in the given row...

so the first row that contains 1, 1, 20, 0, 22, 22 I only want the embedded summary to give me 20 because its the largest number (Not counting the totals) and eventually, the red cell will be the largest number (20)

just using embedded summary to show what the value is.

enter image description here

Thanks!


Solution

  • alright, got it working. Here's the formula I used to create the red borders...

    local numbervar c;
    local numbervar max:=0;
    
    for c:=0 to GetNumColumns-3 do    
    (     
        local numbervar value:=GridValueAt(CurrentRowIndex, c, CurrentSummaryIndex);
        if value > max then max:=value;
    );
    
    if gridvalueat(CurrentRowIndex,CurrentColumnIndex,CurrentSummaryIndex) = max then crred else crnocolor
    

    and for the embedded summary, just change the last line to

    max;