Create Client Calculations in Table Cells

In SAP Analytics Cloud, you can add calculated rows and columns to your table, or even create calculations and formulas within the table.

There may be situations where you prefer to add client calculations directly to the table rows or columns and you can do that for less complex calculations.

However, if you want to create calculated or restricted measure calculations or other complex calculations, you will need to access the Builder panel and create those calculations using the Calculation Editor.

For more information, see Create Custom Calculations for Your Tables.

Add Calculated Rows and Columns

While you can still create calculated members based on the Account or Structures/Cross Calculations dimensions using the Calculation Editor, creating calculated rows and columns can provide more flexibility. For example, you don't really need to create a restricted measure to calculate the variance between an Actual and a Budget version.

You can create a calculated row or column that is Repeating or Single:
  • Repeating: uses one dimension member as anchor and the calculation appears wherever that dimension member appears.

  • Single: uses multiple dimension members as anchor and the calculation appears only once.

How to Add a Calculated Row or Column

  1. To add a blank row or column, right-click the header of a dimension member and select Add column (or Add row) and then select either Repeating or Single.

    The calculated row or column is created as a new member of the same dimension and hierarchy level as the member that you selected.

  2. (Optional) Type a name for the calculation in the header cell.

  3. To enter the formula, type the equals sign (=) and then begin typing the formula.

    • Add cell references by typing the coordinates of the member cell (for example, B2), or by selecting the cell to reference.

      The cell must belong to the same table as the calculation.

    • References to cells in a calculated row or column are relative.

      For example, if you type =C2-B2 in a column header, the fifth row of this column will calculate C5-B5, the sixth row will calculate C6-B6, and so on.

    • Create absolute or fixed references to cells.

      For example, if you want to multiply each row by the value in C2, you type =$C$2*B2.

    • The following are some of the most common formulas that you can create.

      Formula

      Example

      Sum

      =B2+C2

      Subtract

      =B2-C2

      Multiply

      =B2*C2

      Divide

      =B2/C2

      Percentage difference

      =(B2-C2)/C2

      Percentage share

      =B2/C2

      Power: a column raised to a power

      =B2^3

    • Apply the =comment() function to create a comment column.

      For example, you can add a reference to a column header (=comment(B2)) to create and display comments for the data cells in that column. (When you export the data to a CSV file, you can also export the comment column.) Double-click a cell or select it and start typing to work with comments.

      For more information about commenting on data cells, see Add Comments to Data Cells in Tables.

  4. To edit, format, or delete a calculated row or column, open the Builder panel and expand the list of calculations for the dimension that the row or column was added to.

    The calculated rows or columns are referred to as Story Calculations in the builder panel. When you select a story calculation and choose (Edit calculation), the calculated column or row is highlighted in the table and the formula is displayed in the formula bar.

Example: Create a Variance Column

To calculate the difference between a Budget and Actuals version, you can add a calculated column based on the Version dimension:
  1. Right-click the column header of the Budget version and select Add column.

  2. To name the new column, select the header, type Variance, and press Enter.

  3. Select the Variance cell again and type the formula. Use the cell coordinates of the Budget and Actuals column headers, or select each column to create references.Use the cell coordinates of the Budget and Actuals column headers, or select each column to create references. For example, =D1-C1. Press Enter.

Table with Actual and Budget columns and a new Variance column showing calculated differences.
Add a calculated Variance column

The new column shows the difference between the Budget and Actual version for each account. You can also perform this calculation using restricted measures based on the Structures/Cross Calculations dimension.

Create Calculations from Table Rows or Columns

Instead of adding a row or column to the table first and then creating a running calculation formula for the measure, you can select a member and pick a formula from the list. These calculations can be added even if you don't have permission to edit the story.

You can also select multiple members and create a calculation from them.

How to Create Calculations from Table Rows or Columns

  1. In your table, do one of the following:

    • Use a single member.

      Right-click a member, select Add client calculation, select one of the calculations, and then select whether you want a repeating dimension or a single dimension.

      • Repeating: adds a column or row based on each recurrence of the dimension member.

      • Single: adds only one column or row based on the combination of dimension members.

      Option

      Function

      Moving Minimum Value

      runningmin ( <value>)

      Moving Maximum Value

      runningmax ( <value>)

      Accumulative Sum

      runningsum ( <value>)

      Accumulative Sum of all Detailed Values that are not Zero, Null, or Error

      runningsum (<value>, true)

      Accumulative Sum of Rounded Values

      runningsum ( round (<value>))

      Accumulative Count of All Detailed Values

      runningcount <value>

      Accumulative Count of all Detailed Values that are not Zero, Null, or Error

      runningcount (<value>, true)

      Moving Average

      runningaverage (<value>)

      Moving Average that is not Zero, Null, or Error

      runningaverage ( <value>, true )

      Rank Number

      rank (<value>)

      Olympic Rank Number

      olympicrank (<value>)

      Comment

      comment (<value>)

    • Use multiple members.

      1. Select two or more members: select one member and then press Ctrl (or Shift) and select one or more members.

      2. Right-click and then select Add client calculation, select one of the calculations, and then select whether you want a repeating dimension or a single dimension.

        • Repeating: adds a column or row based on each recurrence of the dimension member.

        • Single: adds only one column or row based on the combination of dimension members.

        When using multiple members, you can choose from the following calculation options:
        • Sum

        • Subtract

        • Multiply

        • Divide

        • Percentage Difference

        • Percentage Share

  2. To hide the reference (original) column or row, select the member and then select Hide column (or Hide row).

    The calculation or comment column or row is still visible. To show the reference column, remove the Hidden filter from the table.

A new row or column containing calculations is added to the table, and the formula is added to the builder panel as Story Calculations for the dimension.

When you select the header for the calculation row or column, the calculation formula is displayed in the formula bar. The calculation formula will also be displayed when you select (Edit calculation) for the story calculation in the builder panel.

Null Handling for Calculated Table Rows or Columns

Null values in most of the calculations in table rows and columns will be handled in the same way that Microsoft Excel handles null values.

When you are creating calculations in your table rows or columns, null values will be ignored, unless they are explicitly included in a calculation. For example, =if(A10 = null,1,2)

Most of the calculations will be handled in the same way that Microsoft Excel handles these calculations. However, finding the average of two null values will be handled differently. Microsoft Excel shows a divide by zero error, but SAP Analytics Cloud shows a null value instead.

The following table shows the results of basic mathematical operations as well as the result of calculating an average.

It also shows how to test the value of a cell using a client calculation with a formula that contains a Boolean expression.

 

A

B

C

D

E

F

G

H

I

J

1

Time

Jan

Feb

Jan+Feb

Jan-Feb

Jan*Feb

Jan/Feb

Avg(Jan,Feb)

=if(C1=0,"is zero","is not zero")

=if(C1=null,"is null","is not null")

2

Product

                 

3

Tennis shoes

6,00

0,00

6,00

6,00

0,00

DIV0_ERR

3,00

is zero

is not null

4

Running Shoes

2,00

3,00

5,00

-1,00

6,00

0,67

2,50

is not zero

is not null

5

Soccer shoes

7,00

–

7,00

7,00

0,00

DIV0_ERR

7,00

is not zero

is null

6

Average sales per month

5,00

1,50

             

Troubleshooting: Operands with Reference Errors (REF_ERR)

Client calculation formulas can display REF_ERR as operand. Learn more about the reasons and consequences using the following example:

In the table below, you can see a client calculation in cell A4 that is defined with the text “Diff” and the formula =A2-A3. Note that in SAP Analytics Cloud, you can only display the text or the formula using the formula bar, but not both at the same time.

A2 refers to “Shoes”, A3 refers to “Accessories”, both are members of the “Products” dimension.
 

A

B

1

Products

 

2

Shoes

10

3

Accessories

7

4

Diff (=A2-A3)

3

Referenced Member Is Hidden

If you hide a row or column that contains an operand used in the formula (using the table context menus Hide row or Hide column), and you check the formula in the formula bar, the operand will be replaced with 'REF_ERR'.

The hidden values are still available for calculations, but the references to the operands use cell coordinates. Since the referenced cells are hidden, no cell coordinate can be provided for these cells. REF_ERR is displayed instead. However, the formula is calculated correctly.

In the following example, you can see that the row with “Shoes” has been hidden. The corresponding operand is displayed as 'REF_ERR'. “Accessories” is now in A2, and therefore the formula is displayed as =REF_ERR-A2.

 

A

Hidden: “Shoes”

B

1

Products

 

2

Accessories

7

3

Diff (=REF_ERR-A2)

3

Referenced Member Is Not Available

For different reasons, the operand and its values cannot be retrieved from the back-end system and therefore the calculation cannot use the value of the operand. The operand is displayed as 'REF_ERR'. The formula is not calculated correctly and the following error is displayed in the table details:

“Calculation cannot find member <member> (<dimension>).”

The placeholders <member> and <dimension> are replaced by the affected member of a dimension in a model.

The reasons for not retrieving the referred cell can be the following:

  • You have used the table context menu to exclude the member from the filter.

  • You have deselected the corresponding member from one of the filters that influence a table, for example, by using a story filter, a page filter, a local table filter, an input control, variables, or other options.

  • The user viewing the table doesn't have read access to the referenced member.

In the following example, you can see that the row with “Shoes” is not available. The corresponding operand is displayed as 'REF_ERR'. “Accessories” is now in A2, and therefore the formula is displayed as =REF_ERR-A2. The formula is calculated disregarding that the value for “Shoes” is filtered out and is therefore not available for calculations. The result of the calculation changes from 3 to -7.

 

A

Excluded: “Shoes”

B

1

Products

 

2

Accessories

7

3

Diff (=REF_ERR-A2)

-7

Troubleshooting: Missing Anchors

As described at Add Calculated Rows and Columns, client calculations are anchored to a combination of members of one or more dimensions. If an anchor is not part of the result set displayed in the table, the client calculation can no longer be positioned and displayed. The following error is displayed in the table details: “Calculation couldn't be applied. Attached member isn't visible in the grid.”

To resolve this issue, choose an anchor for your client calculation that is always displayed in the table during different interactions with the result set such as filtering, zero suppression, or null suppression. These operations can change the member display in the table.