Start of Content Area

Procedure documentation Defining Formulas  Locate the document in its SAP Library structure

Use

You can recalculate the key figures in a structure using a formula. You can include basic key figures, restricted key figures, and calculated key figures in the formula definition.

Procedure

Defining a Formula

...

       1.      If the query does not yet have a key figure structure, create a New Structure in the Rows or Columns of the Query Designer by highlighting the row or column directory using the secondary mouse button and selecting New Structure from the context menu.

       2.      If the structure does not yet contain any key figures, use drag and drop to transfer a (basic) key figure of the InfoProvider into the directory of the new structure.

       3.      Select the structure directory, and choose New Formula. The New Formula entry is inserted and the properties for the formula are displayed in the Properties screen area.

       4.      Select the New Formula entry and, from the context menu (secondary mouse button), choose Edit. The Change Formula  dialog box appears.

Note

You can also call the Change Formula dialog box from the Properties screen area by choosing the Edit pushbutton.

You make the basic settings on the General tab page.

You enter a description of the formula in the text field provided in the upper part of the screen.

Note

You can use Using Text Variables in the description.

Next to that, you can enter a technical name in the Technical Name field.

The formula entry field is below the text fields. The bottom left screen area contains all of the operands available for defining the formula. These are:

-         The structure elements that you have already defined for the structure

-         The cells that you have defined as exception cells

-         All form variables

On the right side of the screen, you see the functions that are available as operators:

-         Basic functions

Percentage Functions

Data Functions

-         Mathematical functions

-         Trigonometric functions

Boolean Operators

Above these two areas, you see the symbols for the basic arithmetic operations. To the right there is a number block.

Proceed as follows to define a formula:

       Choose the required operands and insert them in the Detail View field by double-clicking or by using drag and drop.

       Choose the calculation functions you want to use by either clicking on the symbols for the basic arithmetic operations, double-clicking on the functions, or using drag and drop.

       Select the numerical values for the formula by clicking on the number block.

Note

You can also enter digits, parentheses and basic arithmetical operations using the keyboard.

       5.      Define your formula using the available operands and operators. With each step, the system checks the syntactic correctness of the formula. If the formula is not yet complete or is not syntactically correct, the system underlines the location of the error in red.

The system does not check whether the formula makes sense semantically, for example, if it contains the same units. Semantic checks are performed with the Check Query function, which you can call in the Functions of the Menu Bar in the Query Designer.

Note

If, when defining a formula, you want to use a variable that is not contained in the operands, you must first create the variable. Highlight the Formula Variable entry and, from the context menu, choose New Formula. You reach the variable wizard. This takes you through a step-by-step process for defining a new variable.

If you want to change a formula variable, select the variable and, from the context menu, choose Edit. The variable editor appears.

Caution

Note that when you execute a query, the key figures are always calculated as the same unit. That is, a formula is semantically incorrect if, for example, a currency unit (for example, USD) is added to a weight unit (for example, kg). If you want to calculate values regardless of the unit, use the function Value Without Dimension (Without Units). See Data Functions.

       6.      Enter a description of the formula.

       7.      Make any necessary settings for the properties of the formula in the other tab pages. See Selection/Formula Propertiess.

       8.      Choose OK. The new formula is defined in the structure.

Editing a Formula

...

       1.      Highlight the formula in the structure and, from the context menu, choose Edit.

Note

You can also call the Change Formula dialog box from the Properties screen area by choosing the Edit pushbutton.

       2.      Make the required changes to the formula definition or in the properties on the corresponding tab page.

       3.      Choose OK.

Defining Properties for the Formula

...

       1.      Select the formula in the structure. The properties dialog box is displayed in the Properties screen area.

       2.      Make the required settings for the technical name, description, display, number format, calculations, aggregation behavior and formula collision in the formula. See Selection/Formula Propertiess.

 

See also:

Technical Notes about the Formula Operators

 

 

 

 

End of Content Area