Creating basic calculations

You can create basic arithmetic calculations for columns with numeric data types.

About this task

The expression for these calculations is predefined, and you need only to select the proper mathematical operator, and in some cases, a constant value. For example, you can create a column Revenue by multiplying values for Quantity and Unit price.

Procedure

  1. In the data module tree, right-click one or two columns that you want to use in the calculation.

    For calculations that are based on two columns, use control-click to select the columns. The columns can be in two different tables. The column that was selected first is used as the first operand in the calculation.

    You can also create the calculations at the folder level.

  2. Click Create calculation.
  3. Specify the calculation name by overwriting the automatically generated name.
  4. For Expression, if your calculation is based on one column, choose the required operator and specify the constant value.

    If your calculation is based on two columns, ensure that the order of columns is correct, and choose the required operator. If the order of columns is incorrect, click Cancel, and start the calculation again by selecting the columns in the proper order.

  5. Leave clear or select the Calculate after aggregation checkbox.

    When you leave this checkbox clear, the calculation is performed on the column values before they are aggregated. If you select this checkbox, the calculation is performed after the values are aggregated. The calculation results might be different in each case.

  6. Click OK to finish the calculation, or click Use calculation editor to view the calculation expression, or to modify it.

Results

A calculation based on one column is created as an embedded calculation. The calculation is added at the top of the list of columns in the table. You can move it to a folder inside the same table.

A calculation based on two columns can be created as an embedded or stand-alone calculation. If the columns are from the same table, an embedded calculation is created. It is added at the top of the list of columns in the table. If the columns are from different tables, a stand-alone calculation is created. It is added at the top of the data module tree, outside of any table. You can move this calculation to a module-level folder.

What to do next

The calculated column can be used in the same way as other columns in the table. From its context menu, you can access the different actions to edit the calculation, format its data, or remove it.

The calculation can be used in reports, dashboards, explorations, and other Cognos® Analytics content.