Search code examples
crystal-reports

Highlight Header Field Based on two Line Detail Variables


Crystal Reports Highlight Group Header Based on Condition in Details

I have read the link above and tried several variations to no avail. Right now I have this crystal syntax that gives no error but, in the report I have one line that meets both of the if criteria, but the header field does not turn yellow.

IF {SO_PickingSheetWrk.ItemType}="1" and SUM({@qty_pulled})>0 then 
    crYellow 
else 
    crNoColor

The itemtype field on the detail lines could have one line = 1 and another line =2 or all lines =1, each one of these items will have a qty_pulled field. I only want to account for the itemtypes=1, so I tried creating a formula to sum up the qty_pulled fields and use that but didn't work.

This is the formula field in the code above.

if {SO_PickingSheetWrk.QTY_PULLED}>0 then
    1
else 
    0

Also tried a simple expression, kind of stuck

IF {SO_PickingSheetWrk.ItemType}="1" and {SO_PickingSheetWrk.QTY_PULLED}<>0 then crYellow else crNoColor

Solution

  • Step 1: create a @Detail_1_0 formula like this:

    IF {SO_PickingSheetWrk.ItemType}="1" and {@qty_pulled}>0 then 1 ELSE 0
    

    Step 2: Use the following to conditionally highlight the header field:

    IF SUM({@Detail_1_0})>0 then 
        crYellow 
    else 
        crNoColor
    

    This assumes the condition is for a Report Header. If this is for a Group Header, then sum the detail-level formula for the group -- not for the whole report.