Ironside Tech Tip: Formatting Based on Report Output
This is the second in a series of articles for the Ironside Cognos Report Studio Cookbook. The first article can be viewed here. These are tips and tricks used by our professional report developers to meet the unique needs and requirements of our clients. While some of these techniques may be touched upon in a typical Report Studio training class, we will take a deep dive into these concepts to uncover how our professionals actually use them in the field every day.
Difficulty: Easy
Required Ingredients: String variable, value prompt, text item, parameter
Scenario
You have an interactive HTML report with an in-report prompt for year. Since the year is not displayed anywhere else in the report, the prompt also serves as a contextual label. However, the users would also like to be able to export to PDF. The problem with that is the value prompt is only visible in interactive HTML. Once the report is rendered in PDF or Excel, the year selected will not be known to the consumer of the report output (as illustrated below).
There are several methods to solve this problem, but we’re going to concentrate on the use of a built-in Cognos function and the Render Variable.
In the example below, we open a simple report in Report Studio that contains a value prompt for Year.
Step 1: From the Toolbox, drag a Text Item next to the Value Prompt.
Step 2: In the text editor, type in Year label and click OK.
Step 3: While still on Text Item, locate the Source Type property and select Report Expression. Click the ellipsis next to the Report Expression property.
Step 4: In the Report Expression editor, click on the Parameters tab and drag p_Year into the Expression Definition box and click OK.
Step 5: While still on the Text Item, locate the Render Variable property and click on the ellipsis.
Step 6: In the Variable dropdown, select <New string variable>.
Step 7: In the New Variable dialog box name field, type vReportOutput. Then click on the New icon.
Step 8: In the Add dialog box, type PDF. Click OK.
Step 9: Click OK on the New Variable dialog box.
Step 10: In the Report Expression editor, click on the Functions tab, expand Report Functions, and locate the function named ReportOutput(). Drag ReportOutput() into the Expression Definition box and click OK.
Step 11: Make sure PDF is checked and click OK.
Step 12: Run the report in both HTML and PDF. Notice the Year label text only shows up in the PDF report output.
Other Applications
This same technique can be used in multiple objects within reports (basically any object that has a Render Variable property). For example, the Table of Contents object in the Toolbox only renders in PDF output, thus an entire report page object could be included or excluded based on report output.