views:

51

answers:

1

I'm pretty new to Crystal Reports and I can create Pie Charts just fine, but I can't figure out how to chart a JOIN. For example, I have two tables "A" and "B". In the "link" tab of the Database Expert I've drug a line so that A.FK goes to B.PK.

Table A      Table B
--------    --------
PK | FK      PK | FK
0  | 1       1  | Gizmos
1  | 1       2  | Gadgets 
2  | 2

The pie chart for A.FK would come out looking correct but the value in A.FK would be used in the legend, when I'm expecting the JOINed value of B.FK. So instead of my chart having two slices called 1 and 2, I want the slices to read Gizmos and Gadgets.

Can anyone please assist? Thanks

+1  A: 

This is because you are grouping the report by A.FK - you need to change it to group by B.FK.

To do this:

  1. Right-click on your chart and select Chart Expert.
  2. In the Chart Expert dialog, click on the Data tab.
  3. Select B.FK from the Available fields, and click on the first > button to add it to the list of grouping fields (to the right).
  4. Select A.FK from the list of grouping fields and click on the first < button to remove it from the list. Your chart should now be grouped on change of B.FK.
  5. Click OK at the bottom of the dialog.
Mark Bannister
When I do that, I see a chart that is 50% Gizmos and 50% Gadgets because the B table has just two entries. What I'm looking for is 2/3 Gizmos and 1/3 Gadgets. The linking in my Database Expert seems to be correct; A.FK -> B.PK.
AuxOne
The **linking** of your tables should be fine - it's the grouping and aggregation that sounds as though it's at fault. As detailed above, you should be **grouping** by B.FK; you should also be summarising the number of rows returned. Return to the data tab of the Chart Expert, click on the Advanced Layout option if this is not already selected, ensure that the chart is grouping On change of B.FK, use the second `<` to remove any Show values and use the second `>` to add A.PK to the Show values. This will probably default to Sum of - use Set Summary Operation to change it to Count, instead.
Mark Bannister
That worked! I had to very meticulously input the details but after reading over your post about 5 times I got the right combination. It was just a matter of grouping the right values with the right "show values". Thanks
AuxOne