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

Distinct Group Totals

Status
Not open for further replies.

PatchesPete

Technical User
Jun 30, 2009
14
US
I need to know the first bin location a part was put in. Part can have multiple detail lines. Sample detail:
DETAIL
PART NAME DATE LOCATION
1 PART_1 1/1/2012 BIN_4
1 PART_1 2/1/2012 BIN_4
1 PART_1 4/1/2012 BIN_4
1 PART_1 6/1/2012 BIN_5
1 PART_1 7/1/2012 BIN_6

2 PART_2 4/1/2012 BIN_1
2 PART_2 5/1/2012 BIN_3

3 PART_3 1/1/2012 BIN_4
3 PART_3 2/1/2012 BIN_12
3 PART_3 4/1/2012 BIN_4
3 PART_3 6/1/2012 BIN_1
3 PART_3 7/1/2012 BIN_6

I created one group when PART changes and took the minimum of the DATE to produce a GH1 similar to this that shows the first bin that part was ever in:
PART NAME DATE LOCATION
1 PART_1 1/1/2012 BIN_4
2 PART_2 4/1/2012 BIN_1
3 PART_3 1/1/2012 BIN_4

Now I want to count how many PART numbers are in each first bin to get results similar to this:
BIN_4 2
BIN_1 1
TOTAL 3

I can't use Running Total Fields because there could be hundreds of bins. I have tried many things and always come up with totals that also count the detail lines.
Any suggestions on how I can just get:
BIN_4 2
BIN_1 1
TOTAL 3

Any assistance is appreciated.
Thanks.
 
I gotta find something better to do with my evenings :)
Try this...
Group by part like you already did
place this formula in the details section
Code:
stringvar array loc ;
numbervar array loc_count ;
numbervar a;
booleanvar new := true;
WhilePrintingRecords;
if recordnumber = 1 then 
(redim loc[1]; loc[1] := {LOCATION}; redim loc_count[1];1);
if {Sheet1_.DATE} = Minimum ({Sheet1_.DATE}, {Sheet1_.PART}) then 
(
    for a := 1 to ubound(loc) do
    (
        if loc[a] = {Sheet1_.LOCATION} then (loc_count[a] := loc_count[a] +1;new := false;1);
    );
    if new = true then
    (
    redim preserve loc[ubound(loc)+1];loc[ubound(loc)] := {LOCATION};
    redim preserve loc_count[ubound(loc_count)+1];loc_count[ubound(loc_count)] := 1;
    1
    );
1
);
"";

then place this formula in the report footer
Code:
stringvar array loc ;
numbervar array loc_count ;
stringvar output;
numbervar a;
WhilePrintingRecords;
for a := 1 to ubound(loc) do output := output  & loc[a] & space(10-len(loc[a])) & totext(loc_count[a],"#") & chr(13);
output := output & "Totals" & space(5) & totext(sum(loc_count),"#");
right click that formula.. select format field.. common tab ... and check can grow

i created an excel spreadsheet with the exact data you gave as an example and it worked great ..
Let me know if we need to do some modifications when you run it on larger data samples..

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Thanks for not sleeping so I could. I can't get it to work but I haven't spent much time on it either. I'll get back to you next week when I can spend more time on it.
Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top