IBM Cognos Tabbed Report Design
Often times developers will get a request to create several different variations of a single report. While this can be done with user prompting or even multiple versions of a report, another option would be to create tabs within a report which would allow for the user to easily switch between variations. In this month’s tech tip we’ll go over how to create this using drill-throughs, a string variable and a conditional block.
The first step is to identify what tabs you’ll want to display. Each one of the tabs will need to be set up individually. In our example (sample included) we’ll use the seven days of the week.
Create a Query
Create a new query to be used solely to hold the tab values. Call it “Tab Query” and create data items for every tab that you’d like to appear. The expression definition should be a string encapsulated in single quotes.
The end result should appear as below.
Create a String Variable
Next let’s go ahead and create a string variable called “Tab Condition”. Define the expression as shown below:
if (ParamValue(‘TabChoice’) is null) then (‘Monday’) else (ParamValue(‘TabChoice’))
This expression will set a default tab value for the report.
Next, we will need to create a string value to correspond to every data item we created in the query.
Note: The values of this variable must exactly match the expression definition of the data items we created. It is not necessary to use single quotes when defining the values of the string variable.
Create a Hidden Value Prompt
Drag a value prompt onto the page. Name the parameter “TabChoice” within the prompt wizard and click “Finish”
Once created, within the properties menu, set the Box Type to “None” in order to make this prompt disappear.
Associate the Query to the Page
Navigate to the page explorer. Select the page we are working on and associate it to the Tab Query we created in the earlier steps.
Navigate back to the report and drag a table object onto the page. Define it with 7 columns and 1 row. Drag Text Items into each one of these cells and name them appropriately with each day of the week. Add 20px of padding to each one of these cells.
Define a Conditional Block
Drag a conditional block below the table.
Set the block variable to “Tab Condition” that we created earlier.
Create Drill Throughs:
At this point we’ll need to save the report (call it Tab Example) in order to create a drill through to itself.
Once saved, select one of the tab text values and select Drill-Through Definitions from the left hand Properties pane. Point the drill-through to the Tab Example report.
Define parameters by passing data item values of the corresponding data item
For example, if you are defining the Sunday drill-through then select the Sunday Tab Item.
Repeat the drill through definitions for every tab value.
Select Variable Conditions and Produce Content
We are almost done. All that’s left to do is to develop your content.
Select the conditional block and change the Current Block property to different values. Each one of the values corresponds to a tab. Place your content within the conditional block and test!
It is a good idea to conditionally format the table cell (tab) to show active versus inactive tabs. This way users will always know which tab they are currently viewing.
Save frequently. Because this report drills through to itself, any changes made will not be reflected until the report is saved.
Included is a sample report xml which you can bring into Report Studio. Tab Report Example
I’ve updated this document with a zipped version of the report XML you can use as a starting point.
This report for tabs looks great but the expression if (ParamValue(‘TabChoice’) is null) then (‘Monday’) else (ParamValue(‘TabChoice’)) returns a parsing error CRX-YXX04010. I am running this in Cognos 10.
Can you explain the error and how to remedy it?
Usually that error is most likely due to a simple parsing error.
I was able to replicate your error by taking my expression definition and removing a single quote to unbalance it. Unbalanced parenthesis may also cause this error.
Start first with all your data items in the query you created in the first step of this tech tip. Make sure all your expressions are properly encapsulated with single quotes. Validate the report.
Next check your string variable for the same parsing errors and validate.
Should you need a working example of this I can send you the report xml.
Thanks for the reply, I would appreciate the xml as I still cannot resolve this issue.
Still no luck – can you provide me with a working example?