Microsoft KB Archive/154072

= ACC: How to Create a Pareto Chart Using Microsoft Graph =

Article ID: 154072

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q154072



Moderate: Requires basic macro, coding, and interoperability skills.



SUMMARY
A Pareto chart provides a simple way of analyzing categorical data. In a Pareto chart, categories are arranged in descending order from left to right as histogram columns, based upon a selected numerical criterion, from highest to lowest values. Then, an ascending plot line for cumulative percentage is overlaid on the histogram chart. In this way, you can quickly view the top percentage categories. This article shows how to create a basic Pareto chart. This example uses the Sales By Category query in the sample database Northwind.mdb.



Method for Making a Pareto Chart
NOTE: In Microsoft Access 2.0, field names in existing tables contain spaces to form two distinct words. For example, the ProductName field is spelled Product Name in version 2.0. If you are following this example using Microsoft Access 2.0, please make the corresponding adjustments.

 Open the sample database Northwind.mdb (or NWIND.MDB in version 2.0). Create the data source for the chart as follows:

 Copy and paste the Sales By Category query to a new query. Name this new query qrySalesbyCategory. Open the qrySalesbyCategory query in Design view. Delete the CategoryID field and the ProductName field. (In Microsoft Access 2.0, delete the Product Name field.) Set the Sort order of the ProductSales field to Descending. Change the query to a Make Table query. In the Make Table dialog box, type tblSalesbyCategory in the Table Name box. Save the query and run it. Accept the message to paste rows to a new table.</li> Close the query.</li> Create a new query. Add the tblSalesbyCategory table to the query. Drag the CategoryName field to the QBE grid.</li>  Make a calculated field to the right of CategoryName. Name it ProductSalesTotal. Set it equal to the ProductSales field from the tblSalesbyCategory table:

<pre class="fixed_text">         ProductSalesTotal: [ProductSales] </li>  Make another calculated field to the right of ProductSalesTotal. Name it CumPct. Set this field equal to the following.

NOTE: In the following example, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this example.

<pre class="fixed_text">         DSum("[ProductSales]","tblSalesbyCategory","[ProductSales]>=" _          & [ProductSalesTotal] _          & "")/DSum("[ProductSales]","tblSalesbyCategory") </li> Save the query and name it qrySalesbyCategoryPareto. Close the query.</li></ol> </li> Create a Chart Form as follows:

<ol style="list-style-type: lower-alpha;"> Create a new form using the Chart Wizard based on the query qrySalesbyCategoryPareto. (In Microsoft Access 2.0, in the Select a Table/Query box, select the qrySalesbyCategoryPareto query. Click the Form Wizards button. In the Form Wizards box, select Graph, and then click OK.)</li> Move all three available fields to the Fields For Chart box. Click Next. (In Microsoft Access 2.0, move all three available fields to to the Fields For Chart box. Click Next. Select Category Name as the field to be on the horizontal axis, and click Next. Select both remaining fields to appear on the legend. Accept the default totaling method of Add(Sum) the numbers, and click Next.)</li> Select the Line Chart as the type of chart to use. Click Next.</li> Double-click SumofProductSalesTotal, and select None for Summarize. (In Microsoft Access 2.0, skip this step.)</li> Click the CumPct field, and drag it underneath the ProductSalesTotal field. (Do not replace ProductSalesTotal, but add CumPct to the Data section.) (In Microsoft Access 2.0, skip this step.)</li> Double-click the SumofCumPct field, and select None for Summarize. Click Next. (In Microsoft Access 2.0, skip this step.)</li> For the chart title, type Sales by Category - Pareto, and then click Finish. (In Microsoft Access 2.0, type the chart title Sales by Category - Pareto. Click Modify the design of the form or the graph, and then click Finish.)</li></ol> </li> Update the form's design view with the graph's actual data:

<ol style="list-style-type: lower-alpha;"> Set the graph's Enabled property to Yes and Locked property to No.</li> Close and save the form.</li> <li>Open the form in Form view.</li> <li>Click the Graph object so it has the focus.</li> <li>On the Edit menu, point to Chart Object and then click Open to start Microsoft Graph. Note that Microsoft Graph displays the actual data.</li> <li>On the File menu, click Update.</li> <li>On the File menu, click Exit & Return to <FormName>.</li> <li>Close the form.</li></ol> </li> <li>Modify the Chart Design as follows:

<ol style="list-style-type: lower-alpha;"> <li>On the View menu, click Form Design. (In Microsoft Access 2.0, the form will already be open in Design view.)</li> <li>Using the right mouse button (right-click), click the chart in Form design, click Chart Object, and then click Edit.</li> <li>Right-click the vertical axis, and select Format Axis. Click the Number tab. Select the Currency category, and then click OK.</li> <li>Right-click the horizontal axis, and select Format Axis. (You may need to click slightly below the axis to avoid selecting the data series).</li> <li>Click the Alignment tab, and choose the label alignment to be automatic. Click OK. (Choose vertical rather than horizontal in earlier versions. Click OK.)</li> <li>Right-click the ProductSalesTotal data series. Select Chart Type, select Column, and then click OK.</li> <li>Right-click the CumPct data series. Select Format Data Series.</li> <li>Click the Axis tab. For "Plot Series on...," click Secondary Axis, and then click OK.</li> <li>Right-click the new vertical axis that is on the right side of the chart. Select Format Axis. Click the Number tab. Select the Percentage category, and then click OK.</li> <li>Resize the chart with the mouse pointer to make more room for the legend. Resize and move the legend to an appropriate place on the chart.</li> <li>On the File menu. click Update. On the File menu, click Exit & Return.</li> <li>Size the chart control in the form with your mouse pointer to give it a reasonable size.</li> <li>Save the form as frmPareto. View the chart in Form view.</li></ol> </li></ol>

This will give you a Pareto chart showing the ordered product sales categories and their corresponding percentages.

<div class="references_section">