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
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.
Type | Description |
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.
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.
Click the add button and
click New Conditional Style.
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.
Type a name for the conditional style.
If you want to define a value, date/time, date, time, or interval condition, do the following:
Click the new button and type or select a value to define a threshold.
The value appears under the Range column, and two ranges are created.
For each range, under Style, click one
of the predefined styles that you want to apply to the range, or
click the edit style button and
create a new style.
Tip: You can also define a style for the cells in your report that have missing values.
Repeat to add other values.
Tip: Under Style,
pause the pointer over each range to
see the condition produced for each range.
If you want to move a value above or below a threshold, click
the arrow button next to the value.
For example, you insert a threshold value of five million. By default, the ranges are less than or equal to five million and greater than file million. Moving the five million value above the threshold changes the ranges to less than five million and greater than or equal to five million.
If you want to define a string condition, do the following:
Click the new button and select how to define the condition.
If you want to select one or more individual values, click Select multiple values and click the values you want.
If you want to type specific values, click Enter values and type the values you want.
If you want to specify your own criteria, such as begins with the letter A, click Enter string criteria and specify your condition.
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).
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.
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.
Click the add button ,
click Use Existing Conditional Style, and select
the style you want to use.
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.
Click the add button and
click Advanced Conditional Style.
Type a name for the conditional style.
Click the new button and specify the expression that defines the condition.
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).
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.
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 .
From the Tools menu, click Manage Conditional Styles.
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.
Create a variable and define the condition that determines if the data will be highlighted.
In the work area, click the column that you want to highlight based on the condition you created.
In the Properties pane, double-click the Style Variable property.
Click Variable, click the variable you want to assign to the object, and click OK.
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.
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.
Click OK.
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.
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.
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.
You can specify which objects are rendered when a report is run. You can:
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.
Pause the pointer over the condition explorer button and click Variables.
In the Insertable Objects pane, drag one of the following variables to the Variables pane:
To create a variable that has only two possible values, Yes and No, drag Boolean Variable.
To create a variable whose values are string-based, drag String Variable.
To create a variable whose values are different languages, drag Report Language Variable.
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.
If you created a string variable, do the following:
In the Expression Definition box, define the condition and click OK.
For example, the following expression returns the value high if revenue is greater than one million dollars and the value low if revenue is less than or equal to one million dollars.
if ([Revenue]>1000000) then ('high') else ('low')
For information about creating expressions, see Using the Expression Editor.
Click the add button under
the Values pane.
For each value that the variable can assume, type the name of the value that corresponds with the possible outcomes defined in the expression.
Click OK.
For example, in the previous expression, you must create two values for the variable, high and low.
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.
Select the object that you want.
In the Properties pane, under Conditional, double-click the conditional property to which you want to assign the variable.
Click Variable and click one of the following variable types:
Tip: To use an existing variable, you can select it here.
In the New Variable dialog box, type the name of the variable in the Name box.
If you created a string variable, click the add button and type the string values you want to define,
and click OK.
If you created a language variable, select the languages you want to support, and click OK.
In the Expression Definition box, define the condition and click OK.
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 .
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.
In the Insertable Objects pane, on
the Toolbox tab ,
drag the Conditional Blocks object to the work
area.
Click the conditional block.
In the Properties pane, double-click the Block Variable property.
Click Variable, click the variable you created, and click OK.
Click the Current Block property and click Yes.
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 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.
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.
In the Properties pane, double-click the Render Variable property.
Click Variable and click the variable that will be used to determine if the column is to be rendered.
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.
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.
In the Cognos Connection Welcome page, click the Public Folders link.
Click the GO Data Warehouse (query) link, click the Launch link in the upper-right corner of the page, and then click Report Studio.
In the Welcome dialog box, click Create a new report or template.
In the New dialog box, click List and click OK.
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:
Date (in Time dimension)
Order number (in Sales order)
Product name (in Product)
Product description (in Product)
Quantity (in Sales fact)
Unit price (in Sales fact)
Revenue (in Sales fact)
Click Date and click the section button .
Group the Order Number column by selecting the column and clicking the group button.
Click Revenue, click the aggregate
button , and click Total.
Change the title of the report to New Orders.
Pause the pointer over the page explorer button and select Prompt Pages.
Create a new prompt page by double-clicking Page in the Insertable Objects pane.
Double-click the new prompt page.
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.
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.
In the Insertable Objects pane, on the Toolbox tab, drag Text Item into the upper-left cell and type the following text:
Starting Date
In the Insertable Objects pane, drag a Text Item into the lower-left cell, and type the following text:
Show Descriptions
In the Insertable Objects pane, drag a Date Prompt into the upper-right cell.
In the Prompt Wizard window, select Create a new parameter and type p_Date in the space provided, then click Next.
When prompted in the Create Filter window, select Create a parameterized filter with the following entries:
For Package item, click the ellipsis (...) button and click [Sales (query)].[Time dimension].[Date].
For Operator, click >.
Click Finish.
In the Insertable Objects pane, drag a Value Prompt into the lower-right cell.
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.
Select the Value Prompt, and in the Properties pane, double-click Static Choices.
Click the add button .
In the Edit dialog box, type Yes in both the Use and Display boxes.
Click the add button.
In the Edit dialog box, type No in both the Use and Display boxes.
Click OK.
Pause the pointer over the condition explorer button and click Variables.
Create a new boolean variable by double-clicking Boolean Variable in the Insertable Objects pane.
In the Report Expression dialog box, type the following in the Expression Definition window:
ParamDisplayValue("p_ShowDesc") = 'Yes'
Click OK.
Click the new boolean variable that you created and in the Properties pane, for the Name property, type showDesc.
Pause the pointer over the page explorer button and click the report page.
Click the Product descriptions column.
In the Properties pane, select the
list column by clicking the select ancestor button and selecting List Column from
the context menu.
In the Properties pane, double-click the Render Variable parameter and select the showDesc boolean variable you created in steps 24 to 33.
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 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.
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.
From the File menu, click Conditional Layouts.
Select a variable, and then select the values that require a separate layout.
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.
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:
The data then appears in the language and with the regional settings specified in
the user's Web browser options
the run options
the Cognos Connection preferences
Any text that users or authors add appears in the language in which they typed it.
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.
Create a report language variable.
In the work area, click the object that you want to modify based on one of the languages you selected.
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.
Click Variable and click the language variable you created.
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.
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.
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.
Press Enter when you are done.
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.