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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Summarizing Multiple Fields Plus a GrandTotal

Status
Not open for further replies.

omcompany

Programmer
Aug 30, 2011
29
US
I am trying to get the sum of three number fields. Once that has been accomplished I need to have a grand total of those sums.

I am using Crystal 11 connected to an Access db.

To this point I am able to get everything I need by placing the fields in the Details section. All of the data comes from one table, “Summary”.

My data looks like this coming in;

Line/ShotPoint, ChargeWeight_1, ChargeWeight_2, ChargeWeight_3
123 1.1 1.1 2.2
124 2.2 1.1
125 2.2 1.1

What I need to show is;
Line/ShotPoint, Weight_1, Weight_2, Weight_3,@ShotPointTotal
123 1.1 1.1 2.2 4.4
124 2.2 1.1 3.3
125 2.2 1.1 3.3
@GrandTotal 11.0


NOTE: The value for ChargeWeight_3 is usually NULL.

I have tried the following;

For the ShotPointTotal I have tried to create a subreport with variables grouped by Line/ShotPoint. It has not worked so far. Results have been returning 0 at best.

I have three (3) “reset” formulas placed it the Group Header a.
//@Reset
WhilePrintingRecords;
NumberVar Weight1 :=0

//@Reset2
WhilePrintingRecords;
NumberVar Weight2 :=0

//@Reset3
WhilePrintingRecords;
NumberVar Weight3 :=0

For my formula placed in the Details section
//@ChargeWeightSum
WhilePrintingRecords;
NumberVar Weight:= {Summary.ChargeWeight_1};
NumberVar Weight2:= {Summary.ChargeWeight_2};
NumberVar Weight3:= {Summary.ChargeWeight_3};
//NumberVar ShotPointWeight := Weight + Weight2 = Weight3;
//I commented out the last line during testing since it was giving me an error, “A number is required //here.”

For my display formula, placed in the Group Footer #1
//@Display
WhilePrintingRecords;
NumberVar ShotPointWeight;
ShotPointWeight;


For the GrandTotal I have tried;

//@GrandTotalWeight
{Summary.ChargeWeight_1} + {Summary.ChargeWeight_2} + {Summary.ChargeWeight_3}
Placed in the Main Report, Report Footer. If I remove the last “+{Summary.ChargeWeight_3}” I get a result but not the desired one. This may be because of the NULL results?


Any help would be greatly appreciated.
 
The simplest solution would be for you to go to file->report options and choose "convert nulls to default values". Then you could just create a formula like this:

{table.chargeweight_1}+{table.chargeweight_2}+{table.chargeweight_3}

Add this as your fourth column. For the grand total, right click on this formula and insert a sum on it.

-LB
 
LB

Thank you once again for your time. Your help is appreciated and your solution works as expected. I am embarrassed at how much time I put into this and was not really in the same ball park. I will learn from your solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top