Example - Create a Conditional Report

You are a report author at The Sample 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.

Procedure

  1. Open IBM® Cognos® Report Studio with the GO Data Warehouse (query) package.
  2. In the Welcome dialog box, click Create a new report or template.
  3. In the New dialog box, click List and click OK.
  4. From the Source tab 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.
  5. Click Date, and then click the section button section icon.
  6. Select the Order Number column and click the group button group/ungroup icon.
  7. Click Revenue, and then click the summarize button aggregate icon and click Total.
  8. Change the title of the report to New Orders.
  9. Pause the pointer over the page explorer button page explorer icon and click Prompt Pages.
  10. Create a new prompt page by double-clicking Page in the Toolbox tab toolbox tab.
  11. Double-click the new prompt page.
  12. From the Toolbox tab, double-click Text Item and type the following text:

    Enter the start date, and select if descriptions will be shown.

  13. Insert a 2 by 2 table into the prompt page by clicking the insert table button insert table icon and moving the pointer until four squares are highlighted in a 2 by 2 pattern.
  14. From the Toolbox tab, drag a Text Item into the upper-left cell and type the following text:

    Starting Date

  15. From the Toolbox tab, drag a Text Item into the lower-left cell and type the following text:

    Show Descriptions

  16. From the Toolbox tab, drag a Date Prompt into the upper-right cell.
  17. In the Prompt Wizard window, select Create a new parameter, type p_Date in the space provided, and then click Next.
  18. 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 >.
  19. Click Finish.
  20. From the Toolbox tab, drag a Value Prompt into the lower-right cell.
  21. 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.
  22. Select the Value Prompt and, in the Properties pane, double-click Static Choices.
  23. Click the add button add icon.
  24. In the Edit dialog box, type Yes in both the Use and Display boxes.
  25. Click the add button.
  26. In the Edit dialog box, type No in both the Use and Display boxes.
  27. Click OK.
  28. Pause the pointer over the condition explorer button condition explorer icon and click Variables.
  29. From the Toolbox tab, create a new Boolean variable by double-clicking Boolean Variable.
  30. In the Report Expression dialog box, type the following in the Expression Definition window and click OK:

    ParamDisplayValue("p_ShowDesc") = 'Yes'

  31. In the Properties pane, set the Name property to showDesc.
  32. Pause the pointer over the page explorer button and click the report page.
  33. Click the Product descriptions column.
  34. In the Properties pane, click the select ancestor button select ancestor icon and click List Column.
  35. In the Properties pane, set the Render Variable property to the showDesc Boolean variable you created.
  36. Run the report.

Results

The report prompts you for a date. Orders that occur after the date you entered are shown. The report also asks whether to show the Descriptions column, and the column is rendered only if you choose Yes.