,

Ironside Tech Tip: Conditional Blocks – Applications and Usages

day night transition conditional blocks concept

Synopsis

How to create, implement and use conditional blocks in Cognos reports.

Overview

Conditional blocks show different display results based on user interaction or parameters read in when a report is run. They provide a creative method for presenting either the same report data in various formats or executing several completely different reports from one prompt page.

This whitepaper will discuss the process for creating and programming a conditional block. It goes through one potential scenario to paint a clear picture of some possible usages and applications for this technique.

Types of Applications:
Conditional blocks can be designed to:
A) Use a prompt page and prompts as a way to execute one of many reports from a single interface.
B) Embed a prompt into a column/page to effect its values or order.
C) Evaluate the environment (based on the executing user or report output) in which the report is being run and respond appropriately

The following solution demonstrates using a prompt to control which view of a report to display.

Solution Summary:
1) Create multiple data containers on a report page:

Multiple Data Containers

2) From the Toolbox tab, drag a conditional block onto the page:

Toolbox
3) Add a regular block and a value prompt onto the report page or onto a prompt page if you choose to use one.

Add regular block
4) Drag a value prompt into the regular block.

Drag value prompt
5) Choose to create a new parameter in the value prompt’s wizard, change its name to Choose a Report to Run or a similar appropriate name, and click Finish.

Choose a report to run

6) Select the value prompt and double-click Static Choices under Data in its Properties pane.

Static choices for conditional blocks

7) Click on the Add icon, enter your desired display values (what users will see in the menu) and use values (the actual parameter value that will be evaluated in step 10), and click OK.

Add static choices to conditional blocks

8) Hover over the Condition Explorer (a.) and click Variables (b.).

Condition Explorer
9) Drag and drop a String Variable object into the Variables list. (Boolean is used for simple true/false evaluation whereas a String Variable allows for more than one possibility).

String variable
10) In the Report Expression window that pops up, switch to the Parameters tab (a.) to use the value prompt parameter you made earlier (b.) and enter a logic statement that will evaluate the choice selected in the value prompt. Click OK to continue. An example expression is shown below:

if ( ParamDisplayValue(‘Choose a Report to Run’) = ‘List’ )
then

(‘List’)

else if ( ParamDisplayValue(‘Choose a Report to Run’) = ‘Crosstab’)
then

(‘Crosstab’)

else

(‘Chart’)

Report Expression Chart
11) Click the Add icon and add the values from step 11.

Add values12) Use the Page Explorer to return to Page 1, select the conditional block you added, and do the following:

a) Go to Render Variable under Conditional in the conditional block’s Properties pane.
b) Choose the logic statement created in step 10.
c) Click OK.

Page explorer render variable for conditional blocks
13) Associate the current view of the conditional block with the element that corresponds to the relevant condition from step 11 by doing the following:

a) In the Properties pane under Conditional, change Current Block to one of the data container choices you set up.

Conditional blocks List property
b) Navigate to the relevant data container (e.g. the list report) and click on the three orange dots in its top left corner to select the entire object.

Navigate relevant data

c) Drag and drop the selected data container into the conditional block

d) Select the Conditional Block and repeat steps b and c for the other data containers.

14) In order to execute the menus selection, click on the value prompt you added and go to Properties > General > Auto-Submit and change the value in the dropdown to Yes.

15) Run the report. Based on the condition the user selects in the prompt, different views will be displayed showing their desired data format.

 

NOTES:

a) Conditional blocks can also be evaluated by using functions such as ReportOutput () to determine if the report is being run in HTML, PDF, or another output format.
b) Extremely sophisticated evaluations can be written to determine environment elements such as time of day or day of week execution, the originating IP address of the requesting user, or the group or role of the executing user.
c) Rendering can be performed by data container(s), columns, or rows within a report.
d) This whitepaper describes the essential steps for implementing conditional blocks. Through creative application of the steps mentioned above, this technique can be leveraged in a variety of reporting situations.