For each crosstab column, highlight maximum value

2019-02-20 02:27发布

问题:

I'm trying to highlight the maximum value in a Crystal Reports crosstab column, per column, i.e. show the best performing salesman in each month.

It seems like a fairly basic requirement, but I can't figure it out! The Highlighting Expert would seem to be the obvious answer, but it only works if you have defined criteria (e.g. Gross Sales > 120,000), and I'm not interested in highlighting the Totals at the end of the columns/rows....I just want the highest value row per column.

回答1:

This is much more difficult than it needs to be...

Add this text to the summary field's "Tool Tip Text" conditional-formatting formula:

// this assumes that there is a Total column and that it is the left-most column.

Numbervar max:=0;
local Numbervar col;

// exclude (left-most) total column
for col := 1 to GetNumColumns-1 do (

    local numbervar value := GridValueAt (CurrentRowIndex, col, CurrentSummaryIndex);
    if value > max then max := value;

);

ToText(max,"#");

Then add this text to the same field's "Style" conditional-formatting formula:

Numbervar max;

If GridValueAt (CurrentRowIndex, CurrentColumnIndex, 0) = max Then
    crBold
Else
    crRegular