To use Cognos product documentation, you must enable JavaScript in your browser.

Customizing Reports Using Conditions

You can define conditions to control what users see when they run a report. Conditions can apply to specific items in a report. For example, you can define a conditional style to highlight exceptional data, such as product revenue that exceeds your target.

Conditions can also apply at the report layout level. Conditional layouts are useful for delivering reports to a multilingual audience. For example, you can have text items, such as titles and cover pages, appear in the same language as the data in the report.

You can use conditions to

Highlight Data Using Conditional Styles

Add conditional styles to your report to better identify exceptional or unexpected results. A conditional style is a format, including such things as cell shading or font color, that is applied to objects if a specified condition is true.

For example, you want to automatically highlight in green departments in your organization that meet their budget quotas and highlight in red the departments that go over budget. Creating conditional styles quickly and easily color-codes information in your reports so that you can find areas that need attention.

You can apply multiple conditional styles to objects. For example, you can apply one style for data formats in specific cells and another style for the overall report. If multiple styles set the same property, such as font color, the last style in the list is applied.

You can also create a conditional style once and reuse it on multiple objects in your report. And you can specify the order in which styles are applied. In addition, you can use existing local classes as your conditional styles.

You can create the following types of conditional styles.

TypeDescription

Numeric Range

Highlights straight numerical data, such as revenues and losses.

Date/Time Range

Highlights data from specific dates and times.

Date Range

Highlights data from specific dates. For example, you can highlight sales data for specific periods of a fiscal year.

Time Range

Highlights data from specific times.

Interval

Highlights data falling between set intervals.

String

Highlights specific alphanumeric items in a report. For example, you may want to highlight all instances of a specific word or phrase, such as Equipment. String criteria are case-sensitive.

If multiple string conditions are met, only the style of the first condition is applied.

Advanced

Creates conditional styles that use calculations or expressions.

If multiple advanced conditions are met, only the style of the first condition is applied.

For more information about creating conditional styles using variables, see Highlight Data Using Style Variables.

You can perform a search to find objects in your report that use conditional styles . You can also view all the conditional styles used in your report so that you can delete or modify them .

You can also use variables to highlight data . If a report contains both conditional styles and style variables, the style variables are applied first and then the conditional styles are applied.

Steps to Create a New Conditional Style
  1. Click the object for which you want to define a conditional style, and then click the conditional styles button .

    Tip: You can also right-click the object and click Style, Conditional Styles, or in the Properties pane, double-click the Conditional Styles property.

  2. Click the add button  and click New Conditional Style.

  3. Select the data item that you want to use to determine the condition.

    Depending on the type of data item you select, Report Studio selects the type of conditional style that you can use.

  4. Type a name for the conditional style.

  5. If you want to define a value, date/time, date, time, or interval condition, do the following:

  6. If you want to define a string condition, do the following:

Steps to Reuse an Existing Conditional Style
  1. Click the data item for which you want to define a conditional style, and then click the conditional styles button .

    Tip: You can also right-click the item and click Style, Conditional Styles, or in the Properties pane, double-click the Conditional Styles property.

  2. Click the add button , click Use Existing Conditional Style, and select the style you want to use.

Steps to Create an Advanced Conditional Style
  1. Click the data item for which you want to define a conditional style, and then click the conditional styles button .

    Tip: You can also right-click the item and click Style, Conditional Styles, or in the Properties pane, double-click the Conditional Styles property.

  2. Click the add button  and click Advanced Conditional Style.

  3. Type a name for the conditional style.

  4. Click the new button and specify the expression that defines the condition.

  5. For each condition, under Style, click one of the predefined styles that you want to apply, or click the edit style button  and create a new style. Specify the style to apply to remaining values by clicking one of the predefined styles beside Remaining values (including future values).

  6. Specify the order in which to evaluate the conditions.

    Conditions are evaluated from top to bottom and the first condition that is met is applied.

Manage Conditional Styles

If your report uses conditional styles, you can easily see all the ones that are applied to your report. You can then easily globally modify or delete them. You can also define a new conditional style that you can make available for objects in your report.

In the Report Studio options, you can specify whether to automatically delete conditional styles that are no longer used in a report .

Step

Highlight Data Using Style Variables

Highlight data in your report to better identify exceptional results. For example, you want to identify sales representatives who have exceeded their quota. You create a condition that checks whether each representative’s sales for the year is greater than their quota for the year.

Use style variables if you are working with reports created in a previous version of Cognos 8 or if you want to use language variables to specify conditional styles.

You can also use conditional styles to highlight data . If a report contains both conditional styles and style variables, the style variables are applied before the conditional styles.

Steps
  1. Create a variable and define the condition that determines if the data will be highlighted.

  2. In the work area, click the column that you want to highlight based on the condition you created.

  3. In the Properties pane, double-click the Style Variable property.

  4. Click Variable, click the variable you want to assign to the object, and click OK.

  5. If you assigned a string variable, in the Values box, select the values you want the condition to support.

    Tip: A default value exists for the variable, and it is always selected.

  6. If you assigned a language variable, in the Values box, select the languages you want the condition to support.

    Tip: A default value exists for the variable, and it is always selected.

  7. Click OK.

  8. Pause the pointer over the condition explorer button , and click one of the possible values for the variable other than the default value.

    Tip: When you select a value in Condition Explorer, the Explorer bar becomes green to indicate that conditional formatting is turned on, and that any changes you make to the report applies only to the variable value.

    For example, if you created a boolean variable, click the Yes value.

  9. In the Properties pane, specify the formatting that you want to highlight the column with when the condition is satisfied.

    For example, click the Border property to create a thicker border around the column.

  10. Repeat steps 9 to 10 for other possible values defined for the variable.

    Tip: When pausing the pointer over the condition explorer button, click (No variable) to view how the report looks when no variable is applied. Or you can triple-click the Explorer bar.

When you run the report, the report objects to which you applied the variable are highlighted when the condition is satisfied. For example, if you created a boolean variable, the objects are highlighted when the condition is met. If the condition is not satisfied for any object, no conditional formatting is applied.

Adding Conditional Rendering to a Report

You can specify which objects are rendered when a report is run. You can:

Add a Variable

Before you can add conditional formatting or conditional rendering to your report, you must add a variable in the condition explorer or in the Properties pane.

Steps in the Condition Explorer
  1. Pause the pointer over the condition explorer button  and click Variables.

  2. In the Insertable Objects pane, drag one of the following variables to the Variables pane:

  3. If you created a boolean variable, in the Expression Definition box, define the condition and click OK.

    For example, the following expression returns the value Yes if revenue is less than one million dollars and the value No if revenue is greater than or equal to one million.

    [Revenue]<1000000

    For information about creating expressions, see Using the Expression Editor.

  4. If you created a string variable, do the following:

  5. If you created a language-specific variable, in the Languages dialog box, select the languages you want to support and click OK.

    Tip: You can create a group by clicking two or more values and then clicking the group values button. For example, you can create a group that includes all of the different French languages available.

Steps in the Properties Pane
  1. Select the object that you want.

  2. In the Properties pane, under Conditional, double-click the conditional property to which you want to assign the variable.

    Goal

    Conditional Property

    Specify a variable based on which text can be conditionally shown.

    For example, you want different text to appear when a report is run in a different language.

    Text Source Variable

    Specify a variable based on which object can be conditionally rendered.

    For example, you want to make a revenue report smaller by not rendering rows that are below a threshold.

    Render Variable

    Specify a variable based on which object can be conditionally styled.

    For example, you want data that meets some criterion to appear in a different color.

    Style Variable

    Specify a variable based on which objects inserted into a block can be conditionally rendered. Applies only to conditional block objects that you insert in a report .

    Block Variable

  3. Click Variable and click one of the following variable types:

    Tip: To use an existing variable, you can select it here.

  4. In the New Variable dialog box, type the name of the variable in the Name box.

  5. If you created a string variable, click the add button  and type the string values you want to define, and click OK.

  6. If you created a language variable, select the languages you want to support, and click OK.

  7. In the Expression Definition box, define the condition and click OK.

Hide and Show Objects

You can hide and show objects in a report based on a condition you define.

You can also specify that an object should not be rendered based on a condition .

Steps
  1. Create a variable and define the condition that determines if the object is to be shown or hidden.

    Tip: Create a boolean variable to show and hide objects, as this type of variable has only two possible values.

  2. In the Insertable Objects pane, on the Toolbox tab , drag the Conditional Blocks object to the work area.

  3. Click the conditional block.

  4. In the Properties pane, double-click the Block Variable property.

  5. Click Variable, click the variable you created, and click OK.

  6. Click the Current Block property and click Yes.

  7. In the Insertable Objects pane, drag the object you want to show or hide in the conditional block.

    For example, drag a data item from the Source tab or from the Data Items tab.

    You may need to link the report page to a query before you can add a data item to the block.

When you run the report, the report objects to which you applied the variable are visible when the condition is satisfied and invisible when it is not.

Add Conditional Rendering

Add conditional rendering to specify which objects are rendered when a report is run. This is useful when your report contains sensitive data.

Conditional rendering is not the same as showing or hiding objects. When you hide an object, the object exists but is transparent. If an object is not rendered, it is not in the report.

For a list of objects that can be rendered conditionally, see the Render Variable property in Report Studio Object and Property Reference.

Steps
  1. Select the list column to be rendered conditionally.

    Tip: You must select the list column, not list column body or list column title. If the body or title is selected, as indicated in the Properties pane, use the select ancestor button  to select the list column.

  2. In the Properties pane, double-click the Render Variable property.

  3. Click Variable and click the variable that will be used to determine if the column is to be rendered.

  4. In the Render for box, select the values you want the condition to support and click OK.

    Tip: A default value exists for the variable, and it is always selected.

Example - Create a Conditional Report

You are a report author at The Great Outdoors Company, which sells sporting equipment. You are requested to create a report that shows orders after a date specified by the user. The report will prompt the user for a date, and will also ask whether the user wants to see a description for each order.

Steps
  1. In the Cognos Connection Welcome page, click the Public Folders link.

  2. Click the GO Data Warehouse (query) link, click the Launch link in the upper-right corner of the page, and then click Report Studio.

  3. In the Welcome dialog box, click Create a new report or template.

  4. In the New dialog box, click List and click OK.

  5. In the Insertable Objects pane, on the Source tab , expand Sales and Marketing (query), and Sales (query). Add the following data items to the list:

  6. Click Date and click the section button .

  7. Group the Order Number column by selecting the column and clicking the group button.

  8. Click Revenue, click the aggregate button , and click Total.

  9. Change the title of the report to New Orders.

  10. Pause the pointer over the page explorer button  and select Prompt Pages.

  11. Create a new prompt page by double-clicking Page in the Insertable Objects pane.

  12. Double-click the new prompt page.

  13. In the Insertable Objects pane, on the Toolbox tab , double-click Text Item and type the following text:

    Enter the start date, and select if descriptions will be shown.

  14. Insert a 2 by 2 table into the prompt page using the insert table button, and moving the pointer until four squares are highlighted in a 2 by 2 pattern.

  15. In the Insertable Objects pane, on the Toolbox tab, drag Text Item into the upper-left cell and type the following text:

    Starting Date

  16. In the Insertable Objects pane, drag a Text Item into the lower-left cell, and type the following text:

    Show Descriptions

  17. In the Insertable Objects pane, drag a Date Prompt into the upper-right cell.

  18. In the Prompt Wizard window, select Create a new parameter and type p_Date in the space provided, then click Next.

  19. When prompted in the Create Filter window, select Create a parameterized filter with the following entries:

  20. Click Finish.

  21. In the Insertable Objects pane, drag a Value Prompt into the lower-right cell.

  22. When prompted with the Prompt Wizard, Choose Parameter window, select Create a new parameter and type p_ShowDesc in the space provided, and then click Finish.

  23. Select the Value Prompt, and in the Properties pane, double-click Static Choices.

  24. Click the add button .

  25. In the Edit dialog box, type Yes in both the Use and Display boxes.

  26. Click the add button.

  27. In the Edit dialog box, type No in both the Use and Display boxes.

  28. Click OK.

  29. Pause the pointer over the condition explorer button  and click Variables.

  30. Create a new boolean variable by double-clicking Boolean Variable in the Insertable Objects pane.

  31. In the Report Expression dialog box, type the following in the Expression Definition window:

    ParamDisplayValue("p_ShowDesc") = 'Yes'

  32. Click OK.

  33. Click the new boolean variable that you created and in the Properties pane, for the Name property, type showDesc.

  34. Pause the pointer over the page explorer button and click the report page.

  35. Click the Product descriptions column.

  36. In the Properties pane, select the list column by clicking the select ancestor button  and selecting List Column from the context menu.

  37. In the Properties pane, double-click the Render Variable parameter and select the showDesc boolean variable you created in steps 24 to 33.

  38. Click Run.

The report will prompt you for a date, and will then provide orders that occur after the date you entered. The report will also ask whether to show the Descriptions column, and the column will be rendered only if you choose Yes to this selection.

Add Multiple Layouts

Add multiple layouts to show a report in different ways. For example, you can define a different layout for each language in a multilingual report. This allows you to create a single report that can be viewed by report consumers that use different regional settings.

Steps
  1. Create a variable and define the condition that will be used for each layout.

    For example, create a report language variable that includes each language that requires a conditional layout.

    Note: Expressions used in a conditional layout cannot reference a query.

  2. From the File menu, click Conditional Layouts.

  3. Select a variable, and then select the values that require a separate layout.

  4. Click OK.

A layout is created for each value you selected. Pause the pointer over the page explorer button to navigate the different layouts. For each layout, click the Report Pages link to create a report page, or click the Prompt Pages link to create a prompt page , and add the objects you want.

Tip: You can create new variables from the Conditional Layouts dialog. The variables are added to the condition explorer. For more information see, Add a Variable.

Creating Multilingual Reports

You can create reports that show data in more than one language and use different regional settings. This means that you can create a single report that can be used by report consumers anywhere in the world.

The samples databases provided with Cognos 8 store a selection of text fields, such as names and descriptions, in more than 25 languages to demonstrate a multilingual reporting environment. For information about how data is stored in the samples databases and how the samples databases are set up to use multilingual data, see the Administration and Security Guide.

Here is the process for creating a multilingual reporting environment:

      

Use multilingual metadata.

The data source administrator can store multilingual data in either individual tables, rows, or columns.

For more information about configuring your database for multilingual reporting, see the Administration and Security Guide.

      

Create a multilingual model.

Modelers use Framework Manager to add multilingual metadata to the model from any data source type except OLAP. They add multilingual metadata by defining which languages the model supports, translating text strings in the model for things such as object names and descriptions, and defining which languages are exported in each package. If the data source contains multilingual data, modelers can define queries that retrieve data in the default language for the report user.

For more information, see the Framework Manager User Guide.

      

Create multilingual maps.

Administrators and modelers use a Windows utility named Map Manager to import maps and update labels for maps in Report Studio. For map features such as country and city names, administrators and modelers can define alternative names to provide multilingual versions of text that appears on the map.

For more information, see the Map Manager Installation and User Guide.

      

Create a multilingual report.

The report author uses Report Studio to create a report that can be viewed in different languages. For example, you can specify that text, such as the title, appears in German when the report is opened by a German user. You can also add translations for text objects, and create other language-dependent objects.

For more information, see the Report Studio Professional Authoring User Guide.

      

Specify the language in which a report is viewed.

You can use Cognos Connection to do the following:

  • Define multilingual properties, such as a name, screen tip, and description, for each entry in the portal.

  • Specify the default language to be used when a report is run.

    Tip: You can specify the default language on the run options page, in the report properties, or in your preferences.

  • Specify a language, other than the default, to be used when a report is run.

For more information, see the Cognos Connection User Guide.

The data then appears in the language and with the regional settings specified in

Any text that users or authors add appears in the language in which they typed it.

Create a Multilingual Report in Report Studio

You can create a report in Report Studio, that can be viewed in different languages. For example, you can specify that text, such as the title, appears in German when the report is opened by a German user. You can also add translations for text objects, and create other language-dependent objects.

If you want the report to show data in different languages, the model must also be multilingual.

Steps
  1. Create a report language variable.

  2. In the work area, click the object that you want to modify based on one of the languages you selected.

  3. In the Properties pane, double-click the Style Variable property.

    If you are changing the language of a text string, click Text Source Variable instead.

  4. Click Variable and click the language variable you created.

  5. In the Values box, select the languages you want the condition to support and click OK.

    Tip: A default value exists for the variable, and it is always selected.

  6. Pause the pointer over the condition explorer button  and click one of the possible languages for the variable.

    Tip: When you select a value in Condition Explorer, the Explorer bar becomes green to indicate that conditional formatting is turned on, and that any changes you make to the report applies only to the variable value.

  7. In the Properties pane, specify the formatting that you want for the language.

    For example, to change the language of a text string, double-click the Text property, and select the new string.

  8. Press Enter when you are done.

  9. Repeat steps 7 to 9 for all other languages specified for the variable.

    Tip: When pausing the pointer over the condition explorer button, click (No variable) to view how the report looks when no variable is applied. Or you can triple-click the Explorer bar.

When you run the report, the report objects to which you applied the variable are formatted according to the browser’s language.