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!

Simple totals and ratios in a group

Status
Not open for further replies.

raptor999

IS-IT--Management
Sep 2, 2002
3
US
I'm attempting to provide totals on a selected item in a 1:Many relationship. I can get the total number of accounts in a sales region but I can't the get total of SPECIFIC products in the entire sales region. Let's say the product names are "D", "R" and "Y" (not the word 'dry'). These product names are in a character based field. I just need to total all of "D" in a region.
The results should be similar to:
Total Products sold in region 1A is 1250
Total "D" sold is 740
Total "R" sold is 200
Total "Y" sold is 310
Eventially, I'll need the ratio of D/total:
Ratio is 740/1250= x.xx %
etc.
I've tried a couple of things but they haven't worked.
What direction for calculations here (and more advanced) can you provide? Like resources?
TIA!
 
Since you want the total before the actual counts:

Group by Product Names

Drop the Product name field in the details and right click it and select insert->summary->count for the product name group.

Right click it again and select insert->summary->Grand Total

It will appear in the group footer

Drag the grand total to the Group Header, and hide the details section.

Now you can create a formula based on the grand total in a formula by selecting it and selecting the group count field to do the ratio.

-k
 
I tried what was suggested, but I did not get the desired results. I received 0's again. I need to count the number of times that each of the desired products [ProductD, ProductR, and ProductY] have sold in the OrdersItems table and then put them into the same group with each individual total. I may be missing something that you suggested in a nuance. I'll then need to find the ratio of each product [ProductD, ProductR, and ProductY sold for the total set of products sold, which will be different than the total of these 3 products sold.] If I can get the totals for each product, then I can probably get the totals and ratios ok, as I now how the total products sold, but not for the individual products.

So, I have now attempted to use the running totals using a formula approach. Essentially, it's as follows:
#TotalProducts
WhilePrintingRecords;
NumberVar ProductD;
NumberVar ProductR;
NumberVar ProductY;
If {OrdersItems.Product}='D' then ProductD:=ProductD+1;
If {OrdersItems.Product]='R' then ProductR:=ProductR+1;
If {OrdersItems.product}='Y' then ProductY:=ProductY+1;
#TotalProductInitialized
WhilePrintingRecords;
ProductD:=0;
ProductR:=0;
ProductY:=0;
#ProductDdisplay
WhilePrintingRecords;
NumberVar ProductD;
#ProductRdisplay
WhilePrintingRecords;
NumberVar ProductR;
#ProductYdisplay
WhilePrintingRecords;
NumberVar ProductX;

When placing these #ProductDdisplay etc into a single group, I only get one total. [I haven't check the actual totals but they 'seem' ok.]. The other two give 0's. It's only the first one I place in the group footer that seems to total correctly. I'm sure there's a nuance here that I'm not getting.
TIA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top