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. You can create 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 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 and the value low if revenue is less than or equal to one million:
if ([Revenue]>1000000) then ('high') else ('low')
For information about creating expressions, see Using the Expression Editor.
Click the add button in 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.
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 to support.
Select the report object.
In the Properties pane, under Conditional, double-click the conditional property to which to assign the variable.
The following conditional properties are available:
In the Variable box, click an existing variable or one of the following variable types:
In the New Variable dialog box, in the Name box, type the name of the variable.
If you created a string variable, click the add button ,
type the string values to define, and click OK.
If you created a language variable, select the languages to support and click OK.
In the Expression Definition box, define the condition.
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 .
Tip: The Global Bonus Report sample report in
the GO Data Warehouse (analysis) package includes hidden objects.
For more information about The Great Outdoors Company samples, see Sample Reports and Packages.
Create a variable, and define the condition that determines if the object is 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 a Conditional
Blocks object to the work area.
Select the conditional block.
In the Properties pane, double-click the Block Variable property.
In the Variable box, click the variable you created and click OK.
Set the Current Block property to Yes.
In the Insertable Objects pane, drag the object to show or hide to 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 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 the list
column body or the list column title. If the body or title is selected,
as indicated in the Properties pane, click
the select ancestor button and click
the list column.
In the Properties pane, double-click the Render Variable property.
Click Variable and click the variable that will determine if the column will be rendered.
In the Render for box, select the values that the condition will support.
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 ask whether the user wants to see a description for each order.
Open Report Studio with the GO Data Warehouse (query) package.
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) and
add data items to the list:
Expand Time dimension and add Date.
Expand Sales order and add Order number.
Expand Product and add Product name and Product description.
Expand Sales fact and add Quantity, Unit price, and Revenue.
Click Date, and then click the section
button .
Select the Order Number column and
click the group button .
Click Revenue, and then 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
click 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 by clicking
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 a 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, type p_Date in the space provided, and then click Next.
In the Create Filter window, select Create a parameterized filter with the following entries:
For Package item, click the ellipsis (...) button and open Sales (query) and Time dimension, and then click Date.
For Operator, click >.
Click Finish.
In the Insertable Objects pane, drag a Value Prompt into the lower-right cell.
In the Prompt Wizard, in the Choose Parameter window, select Create a new parameter, 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.
In the Insertable Objects pane, create a new boolean variable by double-clicking Boolean Variable.
In the Report Expression dialog box, type the following in the Expression Definition window and click OK:
ParamDisplayValue("p_ShowDesc") = 'Yes'
In the Properties pane, set the Name property to showDesc.
Pause the pointer over the page explorer button and click the report page.
Click the Product descriptions column.
In the Properties pane, click the
select ancestor button and click List Column.
In the Properties pane, set the Render Variable property to the showDesc boolean variable you created.
Run the report.
The report prompts you for a date provides orders that occur after the date you entered. The report also asks whether to show the Descriptions column, and the column is rendered only if you choose Yes.
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.
A layout is created for each value you selected. Use
the page explorer to navigate the different layouts. For each layout,
click Report Pages to create a report page
or Prompt Pages to create a prompt page and
add objects.
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 IBM 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 IBM 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, select the object to modify based on a language.
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 for 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
a language for the variable.
Tip: When you select a value in the condition explorer, the Explorer bar becomes green to indicate that conditional formatting is turned on and that any changes you make to the report apply only to the variable value.
In the Properties pane, specify the formatting 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 6 to 8 for all other languages specified for the variable.
Tip: To view the report with no variables applied, pause the pointer over the condition explorer button and click (No variable) or 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.