stats
stats

Reputation: 465

Highlighting Values in a Crystal Reports Crosstab based on sibling values

I have crosstab which has row columns indicating different classes, and then peoples names across the top.

|         | Required | Person 1 | Person 2 | Person 3 |
| Class 1 | 8      6 | 1      6 | 3      6 | 4      6 | 
| Class 2 | 6      2 | 3      2 | 2      2 | 1      2 |

Each field contains 2 values The first value is the number of hours spent in the class, the second field is the number of hours required for certification.

The Required field id my grand total summary.

In the cross tab expert the fields are defined as follows.

Rows:

Command.descr -> a field containing the class names

Columns:

Command.fullname -> a field containing students full names

Summarized Fields:

Sum of Command.evlength -> summation of all time spent in a given course

Max of @required -> this formula returns the number of required hours based on the course name

I am trying to highlight the field Sum of Command.evlength if it is greater than or equal to the value of Max of @required.

My solution was to perform background formatting. Right-Click on the Sum of Command.evlength field, select Format Field. Click the borders tab, check Background, and enter a formula.

The formula I was using is:

if CurrentFieldValue >= {@required} then color(152, 251, 152) else crNoColor

This is not the correct formula. My crosstab has been placed in the footer, which causes {@required} to contain the last value in the grid which in the above example is 2.

From my research I thought I would have to use GridRowColumnValue(row or column name) to access the value of {@required} in the crosstab, but I could not come up with the correct string to represent it.

Does anyone have a way for me to correctly perform this comparison?

Upvotes: 1

Views: 5292

Answers (1)

Lee Tickett
Lee Tickett

Reputation: 6027

Frustratingly I don't think you can use the highlighting expert to compare to a dynamic value. You could swap the columns round then add the following formulas:

To the max_of_required background colour:

whileprintingrecords;
global numbervar required_hrs := currentfieldvalue;
crNoColor;

To the sum_of_command.evlength background colour:

whileprintingrecords;
global numbervar required_hrs;
if currentfieldvalue >= required_hrs then
 crRed
else
 crNoColor;

I think there are a few other ways but i'm not as confident with those so start here.

Upvotes: 1

Related Questions