Creating a Calculated Field

This section describes how to create a calculated field:

1. First, create the Ad Hoc view to use. To do this, select Create >Ad Hoc View from the menu.

The Data Chooser:Source dialog box appears.

2. In the Data Chooser: Source dialog box, click Domains, select Public > Samples > Domains > Supermart Domain. Click Choose Data.

The Data Chooser window appears.

3. In the Data Chooser window, double-click on Sales to select it and click Table.

A new Ad Hoc view opens.

4. In the Ad Hoc view, click at the top right of the Fields section of the Data Source Selection panel and select Create Calculated Field... from the context menu.

The New Calculated Field dialog box appears, displaying the Formula Builder.

Formula Builder Tab in New Calculated Measure Dialog Box

5. Enter Volume Tier for the Field Name.

Creating the formula:

This section shows how to create a simple text formula that says Low when the Unit Sales amount is under 100 and High otherwise.

Formulas must use the following syntax:

a. Labels for fields and measures must be in double quotes ("): "Customer ID", "Date ordered".
b. Text must be in single quotes ('): '--'.
c. Levels must be in single quotes ('): 'ColumnGroup', 'Total'.
6. Make sure Show arguments in formula is selected.
7. Now create the formula. Double-click on IF() in the Functions list.

Because Show arguments in formula is selected, IF("BooleanFieldName", TrueCalc, FalseCalc) is entered in the Formula Builder.

8. Double-click BooleanFieldName to select it, then double-click Unit Sales 2013 in the Fields and Measures list.

The Formula Builder displays IF("Unit Sales 2013", TrueCalc, FalseCalc).

9. Edit the expression in the Formula Builder to read as follows: IF("Unit Sales 2013" IN (0:100), 'Low', 'High').
10. Click Validate to verify that the formula does not have any syntax errors.

Creating a summary calculation:

The Ad Hoc Editor creates a default summary calculation based on the type of formula you have entered. This section shows how to select a different summary function.

11. Click the Summary Calculation tab.

Summary Tab in New Calculated Measure Dialog Box

12. Select Mode from the Calculation menu.
13. Click Create Field.

The calculated field appears at the bottom of the list of available fields. A special icon indicates it is a calculated field and its name on the list is bolded.

If you have installed the samples, the Ad Hoc view 10. Calculated Fields and Measures includes examples of calculated fields (shown by the icon ) or calculated measures (shown by the icon ). You can explore their formulas by right-clicking on the field or measure name and selecting Edit. You can also create tables, charts, or crosstabs to see how these calculations work in views.

Version: 
Feedback
randomness