Using the expression editor

The expression editor in IBM® Cognos® Analytics is part of the product user interface where you can create and edit calculations, filters, and SQL expressions.

Note: The expression editor in Reporting is not the same. It has a different user interface, and some of the functionality and functions are different.

You access the expression editor when performing the following tasks:

The following screen capture shows the expression editor user interface:

Expression editor user interface

The Components pane includes the data tab Source view icon, and the functions tab Functions view icon.

The data tab Source view icon contains the data module tree. You can drag tables and columns from the tree into the Expression box to create expressions.

The functions tab Functions view icon shows the list of supported functions and operators that you can use in the expressions. You can drag the functions into the Expression box to create expressions. For more information, see Creating expressions. The functions tab is not available in all contexts, for example, when creating SQL tables.

The Expression area is the primary work area to create, edit, or view expressions. Here you can type or paste the expression or SQL code. Then, you can validate the code, and preview the projected columns or table.

The expression editor provides the following syntax validation and editing options:

  • Validation icon in expression editor - Validate the syntax. You can validate the whole statement, or only selected segments of code.
  • Preview icon in expression editor - Preview columns and rows in your projected calculation, filter, or table. If the syntax is not correct, the columns are not displayed.
  • Help icon - View descriptions of functions, and examples of their usage.
  • Comment icon in expression editor - Insert the cursor anywhere in a line of code and select this button to comment out the entire line. To comment out multiple lines of code, select the lines and select this button. The comment string // is added at the beginning of each selected line.
    Tip: To comment out sections of code, manually enclose the text between the following strings: /* and */
  • Prettify code icon in expression editor - Apply formatting to the code.
  • High-contrast icon in expression editor - Use high-contrast mode.
  • Font size icon in expression editor - Change the font size.

For more information about working in the expression editor, including examples, see this article in the IBM Cognos Analytics community.