Microsoft KB Archive/301436

= ACC2002: &quot;Query Could Not Be Processed...&quot; Error with Calculated Total in PivotTable List =

Article ID: 301436

Article Last Modified on 9/26/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q301436



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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
When you create a calculated total within a PivotTable list, you receive the following error message:

The query could not be processed: Formula error - cannot not find dimension member(&quot; &quot;) - in a name-binding function



CAUSE
The expression you entered refers to a detail field from the field list of the PivotTable list. The expression used in a calculated total may only refer to another total.



RESOLUTION
There are different resolutions depending on the results that you want. You can summarize the results of a calculated detail field, or you can create a calculated total based on other totals.

Summarizing a Calculated Detail Field
If you want to summarize data for a calculated expression, create a calculated detail field first, and then create a total from the calculated detail field. The following example demonstrates how to calculate the extended price from the UnitPrice, Quantity, and Discount fields in the Orders and Order Details table in the Northwind sample database. This example first creates a calculated detail field named CalculatedPrice, and then a total that sums the calculated field.  Open the sample database Northwind.mdb. On the View menu, point to Database Objects, and then click Queries. Click the Invoices query in the Database window, and then click Open. On the View menu, click PivotTable View. On the View menu, click Field List to display the PivotTable field list.</li> In the field list of the PivotTable list, drag the following fields to the following locations:

This should display the OrderID field grouped by SalesPerson and OrderDate by Month (Years).</li> On the PivotTable menu, point to Calculated Totals and Fields, and then click Create Calculated Detail Field. This will display the Calculation tab in the property sheet.</li> In the Name box, type CalculatedPrice .</li>  Enter the following expression in the box under the Name: (UnitPrice * Quantity)*(1-Discount) NOTE: You can manually type this expression, or you can add the field names by selecting them in the drop-down box, and then clicking the Insert Reference To button. </li> Click Change. Note that the PivotTable list displays a calculated detail field that calculates the revenue for each line item in the order, minus a discount.</li> Close the property sheet.</li> Click in one of the CalculatedPrice columns in the PivotTable to select it. Note that this automatically selects all CalculatedPrice columns in the PivotTable list.</li> On the PivotTable menu, point to AutoCalc, and then click Sum. This will create subtotals that calculate the sum of the expression for each column and row.</li> Click in one of the OrderID columns in the PivotTable list to select it. Note that this automatically selects all OrderID columns in the PivotTable list.</li> On the PivotTable menu, point to AutoCalc, and then click Count. This will calculate the count of Order Detail records.</li> On the PivotTable menu, click Hide Details. This hides the detail fields, so that only summary data is visible.</li> Click in one of the Sum of CalculatedPrice columns to select it. Note that this automatically selects all Sum of CalculatedPrice columns in the PivotTable.</li> On the View menu, click Properties.</li> Click the Format tab in the property sheet.</li> Set the NumberFormat property to Currency and then close the property sheet.</li></ol>

Note that the PivotTable list displays the sum of the calculated detail field that you created in step 10.

Calculating a Total Based on Other Totals
If you need to create a calculated total that relies on other totals, you must create the other totals first. Then, you can refer to those totals within the calculated total expression. The following example builds upon the steps in the &quot;Summarizing a Calculated Detail Field&quot; section earlier in this article. <ol> If you have not done so, follow all the steps in the &quot;Summarizing a Calculated Detail Field&quot; earlier in this article. This will create a PivotTable list on the Invoices query that calculates a detail field, and then sums it.</li> <li>On the PivotTable menu, point to Calculated Totals and Fields, and then click Create Calculated Total.. This will display the Calculation tab in the property sheet.</li> <li>In the Name box, type AveragePricePerDetail .</li> <li> Calculate the average price by dividing the Sum of CalculatedPrice(total) by the Count of OrderID(total). To enter the expression, use the drop-down box at the bottom of the property sheet to select each total, and then click the Insert Reference To button. The final expression in the box should appear similar to: [Measures].[Total1]/[Measures].[Total2] </li> <li>Click the Change button.</li></ol>

Note that the PivotTable list displays the results of the AveragePricePerDetail calculated total.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

MORE INFORMATION
A PivotTable list total uses an aggregate function, such as Sum, Count, Average, and so on, for summarizing data in a detail field. This is similar to using a Microsoft Access totals query, and selecting an aggregate function in the Totals under a particular field.

A PivotTable list calculated total is an expression that requires one or more PivotTable list totals that use aggregate functions. You cannot refer to PivotTable list detail fields in a calculated total; if you do, you will receive the error listed in the &quot;Symptoms&quot; section earlier in this article. This behavior is similar to trying to use an aggregate function within a Microsoft Access select (non-totals) query. A calculated total is useful when you have already used aggregate functions to summarize data in the PivotTable list, and you then need to perform a calculation with the results of those totals. For example, you could calculate an average by dividing a total that summed a field, by a total that counted another field.

Steps to Reproduce the Behavior
CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

<ol> <li>Follow steps 1 through 6 of the &quot;Summarizing a Calculated Detail Field&quot; section earlier in this article. These steps will create a PivotTable list on the Invoices query, and will display the OrderID field grouped by SalesPerson and OrderDate by Month (Years).</li> <li>On the PivotTable menu, point to Calculated Totals and Fields, and then click Create Calculated Total. This will display the Calculation tab on the property sheet.</li> <li>In the Name box, type Price .</li> <li> Enter the following expression in the box under the Name: (UnitPrice * Quantity)*(1-Discount) </li> <li>Click Change.</li></ol>

Note that you receive the following PivotTable error:

<pre class="fixed_text">The query could not be processed:<BR/> Formula error - cannot not find dimension member(&quot;UnitPrice&quot;) - in a name-binding function

Additional query words: prb

Keywords: kberrmsg kbprb KB301436

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.