Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding two summary fields together in a group

Status
Not open for further replies.

lexi0088

Technical User
Sep 7, 2004
49
I have a report which groups rebates by state. In the group, there are two detail sections. DetailsA includes an NDC amount and DetailsB includes a Notes Amount. I need to add the sum of these two amounts together in order to get a total rebate per state:

{@Rebate}=Sum ({Adjustment Query.Notes Amt}, {Adjustment Query.State})+Sum ({Adjustment Query.NDC Amt}, {Adjustment Query.State})

The problem I run into is when one of the detail sections does not include any amounts, the formula returns nothing. I have tried many formulas, including an IIf statement with an ISNull check in it:

{@Rebate}=IIF(ISNull(Sum ({Adjustment Query.Notes Amt}, {Adjustment Query.State}))=FALSE,Sum ({Adjustment Query.Notes Amt}, {Adjustment Query.State}),Sum ({Adjustment Query.NDC Amt}, {Adjustment Query.State}))

This one also returns a blank value.

Any suggestions would be appreciated.

Thanks

 
Try:

numbervar NotesAmt:=Sum ({Adjustment Query.Notes Amt}, {Adjustment Query.State});
numbervar NDCAmt:=Sum ({Adjustment Query.NDC Amt}, {Adjustment Query.State});
If isnull(NotesAmt) then
NotesAmt:=0;
If isnull(NDCAmt) then
NDCAmt:=0;
NotesAmt+NDCAmt

Should work.

-k
 
I tried entering that formula and it is telling me that there needs to be a field where it says (NotesAmt).

I might need a little hand holding because I am new to Crystal, please forgive me.
 
I don't think you can use isnull with variables. Try:

(
if isnull(sum({Adjustment Query.Notes Amt},{Adjustment Query.State})) then
0 else
sum({Adjustment Query.Notes Amt},{Adjustment Query.State})
) +
(
if isnull(Sum ({Adjustment Query.NDC Amt}, {Adjustment Query.State})) then
0 else
Sum ({Adjustment Query.NDC Amt}, {Adjustment Query.State})
)

-LB
 
That worked beautifully, thank you Lbass
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top