Professional Documents
Culture Documents
Cognos Query Studio: Tool That Allows You To
Cognos Query Studio: Tool That Allows You To
Introduction
This document introduces you to Cognos Query Studio. Query Studio is a web-based reporting tool that allows you to Create reports using your data. Save and reuse reports. View reports in a variety of formats. Print reports.
Prerequisites
To use this training material effectively, you should be familiar with the web and with your departments data. This training is designed to familiarize you with the Cognos reporting tool; it is not designed to familiarize you with the underlying data in UD's system. The training is based on data in a demonstration database. Important Note This training document was designed originally to be used in a class setting. Therefore, the exercises are meant to be followed in a sequence. If you have difficulty working through an exercise, try the first four exercises to familiarize yourself with the basics.
Training Objectives
This class was designed using a desktop computer running the Windows XP operating system and using the Internet Explorer (version 6.0.2) browser. If you use a different type of computer, operating system, or browser, some of the screen graphics may appear slightly different from those printed here. However, the function of the screen (page) should remain the same. After you complete the exercises in this training material, you should be able to do the following: Open the COGNOS Connection web page. Create a report. Add data to the report. Save the report. Run the report. View the report. Recognize the types of reports. Change the appearance of reports. Create crosstab reports. Use charts. Filter, sort, and group data. Perform calculations. 1
Table of Contents
The Cognos Connection Web Site
Exercise 1Open the Cognos Connection Web Site. 4 5 7 8 11 12
Create a Report
Exercise 2Create a Report. Add Data to the Report Exercise 3Add Data to a Report and Save It. Run the Report Exercise 4Run a Report in a Variety of Formats.
Types of Reports
List Reports Grouped List Reports 12 Exercise 5Create a Grouped List Report. Change the Appearance of Reports 15 Change a Reports Title 15 Exercise 6Change a Reports Title. Reorder Report Items 17 Exercise 7Reorder Items in a Report. Change Report Item Names Exercise 8 Change an Item Name in a Report. Set the Number of Rows per Page Exercise 9Set the Number of Rows on a Report Page. Collapse a Report Exercise 10Collapse a Report. Crosstab Reports 20 Create a Crosstab Report Exercise 11Create a Crosstab Report. Sort a Crosstab Report 21 Exercise 12Sort a Crosstab Report. Exercise 13Sort Crosstab Summaries.
Copyright 2008 RajivGupta
17 18 19
20
23
Charts 23 Types of Charts 24 Exercise 15Create a Chart. Exercise 16Create a Chart and Manipulate the Data.
Conventions
The following conventions are used throughout the exercises in this material:
Item
Text you should type Text you should replace Keyboard key names Menu and Window titles
Convention
Courier,bold,10pointfont Courier,bold,italics, 10pointfont
Bold, Uppercase text (e.g., the ENTER key) Bold, mixed-case letters
3. Type your UDel Net ID (UNIX username) in the appropriate field. 4. Type your password in the appropriate field. You should see a window similar to the following:
The Cognos Connection Web Site gives you access to the ReportNet suite of reporting tools: Query Studio and Report Studio. Query Studio allows you to create ad hoc reports from an existing data source. You can edit and save the reports, add features to make them more understandable, print them and more. Report Studio allows offers more options for creating complex reports.
Copyright 2008 RajivGupta
Create a Report
In this class, you will use Cognos Query Studio to create several reports. A newly created report contains no data. You will insert data to add content to your report. Exercise 2Create a Report 1. In the Cognos Connection Web Site window, click the Public Folders tab. You should see a window similar to the following:
2. Click Go Sales and Retailers. Note: Before you can create a report, a UD Cognos administrator must create a package that contains the data you will work with. You will learn the name of the package that contains UD data from the UD Cognos administrator at a later date. (Anyone can create a report using the Go Sales and Retailers training package.) You will see a window similar to the one below with a list of the reports that have been created using the Go Sales and Retailers data:
3. At the top right of the window, click the Query Studio link to open a report: Query Studio You should see a window similar to the one below:
At the top of the left pane is the Query Studio Menushaded in bluewhich lists the commands you can use. Below the menu is a tree structure containing items in the package you are using (in this case, in the GO Sales and Retailers package). To see the items in each category, click the plus sign to expand the category. The following table explains the icons you will see in the expanded tree structure:
Icon
Copyright 2008 RajivGupta
Item
Definition
7
Package (in this case, GO Sales and Retailers) Query Subject Query Item Measure or Fact Filter
End of Exercise
A collection of data tables created by an administrator. A table in the database, for example, Orders. A column of qualitative data in the database, for example, Retailer names. A column of quantitative data in the database, for example, Unit Price. A mechanism for reporting on a subset of data.
You will see the report item columns in the right window pane:
on the toolbar.
6. Type a name for your report. For the purposes of this class, type yourinitials followed by RetailerSales.
Copyright 2008 RajivGupta
7. You may add a description of the report if you wish. 8. Make sure the Option Button next to Public Folders > GO Sales and Retailers is selected and click OK. You may have to scroll down to see the OK button. Note: Category columns appear in the order in which you select them. There are two other ways to insert data into your report: Double-click each item to insert it into the report. Click an item or CTRL+Click multiple items and drag the highlighted item(s) into the report.
End of Exercise
Exercise 4Run a Report in a Variety of Formats. 1. To run a report, click Run Report on the Query Studio menu. You will see a list of options like the one below:
The following table explains the options for running your report:
Copyright 2008 RajivGupta
10
Run with All Data Run with Prompts Preview with Limited Data
Uses all the data for the items you selected. This can take a long time if your data source is large. Asks you to enter information to define the reports content (discussed later in this class). To save time, you can run your report with limited data to determine if the results are what you were expecting. A torn border appears at the top and bottom of the report to indicate that your results are not complete. The quickest way to run your report. You will not see any of your actual data. Instead, data in qualitative categories (e.g., Orders) is represented by letters (abcd) and data in quantitative categories (e.g., Order Number) is represented by numbers (1,234). A torn border appears at the top and bottom of the report to indicate that your results are not complete. Use this option if you want to save a permanent copy of a report at a given time. Also use this option when you want to print your report. Note: Adobe Acrobat Reader must be installed on your system for you to view your report in PDF format. Use the CSV (comma separated values) option if you want to save your results in an Excel spreadsheet. Use the XML option to see an XML representation of the queries, prompts, layouts, and styles in your report.
2. On the Query Studio menu, click Run with All Data. You will see the progress bar at the bottom of the window as your report runs. When it finishes, the window should look similar to the one below:
11
To see all the data in the report, click Page Down to look at each page. You can go to the end of the report by clicking Bottom. 3. On the Query Studio menu, click Preview with Limited Data. You will see the progress bar at the bottom of the window as your report runs. When it finishes, the window should look similar to the one below:
Now your window appears with a torn border. This option is useful only if the person who designed the package you are using included a filter to allow you to see only limited data. Otherwise, the time it takes to run the report will not be lessened by using the option.
5. On the Query Studio menu, click Preview with No Data. You will see the progress bar at the bottom of the window as your report runs. When it finishes, the window should look similar to the one below:
12
Again your window appears with a torn border. This time you see only representative data in the columns. This allows you to make sure your report shows the type of information you expected.
End of Exercise
Types of Reports
You can create three types of reports in Query Studio: List Report When you create a new report and add data to it, the result is always a list report, a representation of your data in rows and columns. The report you created for Retailer Sales beginning in Exercise 2 is a list report. You can manipulate list report data in various ways. As you go through this class, you will add filters and summaries and perform calculations to obtain the information you need. Crosstab Report You can create a crosstab report to show information in summary form. The report still has rows and columns, but the intersection of the rows and columns shows a summary of quantitative information. For example, for the Retailer Sales report, you might create a crosstab report that shows how many of a particular product each retailer sold. Charts You can create a chart to show your information in graphical form. Graphs are produced using at least one qualitative data item (e.g., retailer name) and one quantitative data item (e.g., quantity). There are several types of graphs you can use in Query Studio. These will be explained later in this class.
List Reports
Grouped List Reports As you learned above, the basic Cognos report is a list report. You may have noticed duplicate values in the Retailer Sales report you just created. For example, each retailers name appears multiple times, once for each product the retailer sold. You can manipulate a report to sort the data and to hide duplicate values through a process called grouping. Suppose you create a report that shows the number of product types sold in each sales territory throughout the world. Your report would show duplicates for each product type, producing one entry for each sales territory. You can use grouping to hide the duplicate values, sort the product types alphabetically, and see a summary of items sold for each product type. Exercise 5Create a Grouped List Report with a Filter. 1. To create a new report, click the New Report button on the toolbar. (If you are asked whether you want to save the Retailer Sales report, click Yes.) You will see the new report window in which you can begin to add data. For this report, you
Copyright 2008 RajivGupta
13
will add data using a method different from the one in Exercise 3. 2. In the Go Sales and Retailers package, expand the Products item by clicking the plus sign. 3. Click Product type. 4. Hold down the CTRL key; expand the Countries item and click Sales territory. 5. Continue to hold down the CTRL key, expand the Orders item and click Quantity. Drag the selected items to the right window pane. They will appear in the order in which you selected them. There will be a slight delay while the program processes the data. When it finishes, the window should look similar to the one below.
Your report shows the quantity of all product types sold in each sales territory. You can group by product type to hide the duplicate values in the Product type column. 6. Click the heading of the Product type column. 7. Click the Group button on the toolbar. The window will change, and your columns will look like those below. Each product type appears only once, and a summary for each type has been added.
14
Note: If you want to ungroup a report item, click the column heading and then click the Ungroup button on the toolbar.
Suppose you want to see only the quantity of each product type sold in Central Europe, Northern Europe, and Southern Europe. You can apply a filter to see that subset of the report. To do this: 8. Click the heading of the Sales territory column. The column turns yellow and the heading becomes dark blue. 6. Click the Filter button on the toolbar. You will see a window like the following:
7. In the Show only the following box, click Central Europe, Northern Europe, and Southern Europe. Scroll down and click OK. The window will change, and your columns will look like those below. Now you see the quantity of product types sold in Central Europe, Northern Europe, and Southern Europe. There is also a subheading that shows the values you have used for the filter. Copyright 2008 RajivGupta 15
on the toolbar.
9. Type a name for your report. For the purposes of this class, type yourinitials followed by GroupedProductTypes. (You may add a description of the report if you wish.) 10. Make sure the Option Button next to Public Folders > GO Sales and Retailers is selected and click OK. You may have to scroll down to see the OK button. Note: To remove a filter, click Deselect all in the Filter box.
End of Exercise
16
To open an existing report, you must locate it in the packages (in this case, Go Sales and Retailers) list of reports. 1. At the top right of the Cognos Query Studio window, click Return. This takes you to the Cognos Connection Public Folders tab. Note: If clicking the Return link takes you to the Welcome screen, click Public Folders to get to the Go Sales and Retailers package. 2. Click Go Sales and Retailers. You will see window like the one below with a list of all the reports in the package:
3. To find the reports you have created, click the magnifying glass on the toolbar just above the list of reports. You will see a window like the one below:
4. In the Search string box, type your initials exactly as you did in naming your reports; then click the Search button. At the bottom of the search screen, you will see a Results section with a list of your reports. If you eventually have more than 15 reports, you will have to click Next at the top of the Results section to see all of them. 17
5. Click the Retailer Sales report that you created in Exercise 3 to open it. 6. On the Query Studio menu, click Change Layout; then click Edit Title (alternatively, you can double-click the word Title in your report to open the Title box). You will see a box like the one below:
If you want to add a subtitle, type the text in the Subtitle box. 8. Click OK. Note: If youve added a filter to a report, and you dont want the filter subtitle to appear on your report, uncheck the Show filters box. If you want to remove the title, click Edit Title and then remove the text in the Title box.
End of Exercise
3. Click the heading of the Product name column. 4. Click the Paste button on the toolbar. The Quantity column is now moved next to the Retailer name column and the columns look like those below:
18
Note: When you paste a column, always select the column before which you want it to appear.
End of Exercise
Exercise 8Change an Item Name in a Report 1. Double-click the Product name column heading. At the bottom of the pane, you will see a box like the one below:
2. Highlight Product name and type Product. 3. Scroll down and click OK.
19
Note: If you want to change back to the original name, double-click the Product column heading. Below the Name box, you will see a link with the original name. Clink the link and then click OK to restore the name.
End of Exercise
3. From the drop-down box, select the number of rows you want per page. If you want to number the rows in your report, check the box next to Show row numbers. 4. Click OK. 5. Click the Save button on the Query Studio toolbar to save the Retailer Sales report.
6. At the top right of the report window, click Return. You will return to the list of the reports youve created in Query Studio.
End of Exercise
Collapse a Report
If you have a report with grouping, such as the Grouped Product Types report you created earlier, you can collapse the report to see only certain details. For example, you might want to have your report show only the number of each product type sold in Europe as a whole. Collapsing a report hides successive items. You can expand the report to see the items again. In the following exercise, you will open the Grouped Product Types report, add a new column of information to it, group that information, and collapse the report to show only certain details.
Copyright 2008 RajivGupta
20
Your list of reports should still be open from the previous exercise. If it is not, follow steps 1-3 of Exercise 6 to search for your reports. Exercise 10Collapse a Report 1. Click the Grouped Product Types report to open it. You will now use a new method to add a report item to your report. 2. On the Query Studio menu, click Insert Data. 3. Expand the Products item and click Product name. 4. Drag Product name into the report pane directly to the left of the Sales territory heading. When the column border becomes a bold, flashing line, release the mouse button. The Product name report item column now appears to the left of Sales territory. 5. Click the Product name heading and then click the Group button names and eliminate duplicates. Next, you will collapse the report. 6. Click the Collapse Group button on the Query Studio toolbar. to sort the product
The Sales territory column is (temporarily) removed and your report columns look like those below:
21
7. Click the Collapse Group button again to see the quantity of each product type. If you click Collapse Group a third time, you will see the total quantity of all product types. 8. To see your report as it was before you collapsed it, click the Expand Group button many times as necessary to see each column. 9. Click the Save button to save the report.
End of Exercise
as
Note: There is no notation added when you collapse a report to show that it is collapsed. If you save a collapsed report, and someone else opens it, they have no way of knowing that it actually contains more data than shows on the screen. If you click Expand Group in a report you open, and there is no more data, you will see a message This report cant be expanded any further.
Crosstab Reports
A crosstab report shows your information in summary form. The report will still have rows and columns, but the intersection of the rows and columns shows a summary of quantitative information (a measure).
You now have a report that shows summary information at the intersection of the rows and
Copyright 2008 RajivGupta
22
columns. Notice that a column has been added that shows a summary of each row. 3. Click the Save As button on the toolbar.
4. Type a name for your report. For the purposes of this class, type yourinitials followed by CrosstabSalesTerritories. (You may add a description of the report if you wish.) 5. Make sure the Option Button next to Public Folders > GO Sales and Retailers is selected and click OK. You may have to scroll down to see the OK button.
End of Exercise
Note: If you want to change a crosstab report back to a list report, click the top row (Central Europe, etc.) and then click the Ungroup button on the toolbar.
4. Click a Sort Order and click OK. 5. Remove the Sort Order: follow steps 1-3 above, click Dont sort, and click OK.
Copyright 2008 RajivGupta
23
In the following exercise, you will sort on a measure, namely, the summaries in your Crosstab Sales Territories report to show product type sales from lowest to highest. To make the results clearer, you will first delete the product names from the report. Exercise 13Sort Crosstab Summaries 1. In the Crosstab Sales Territories report, click the Product name (Seeker 35 is at the top) column. Then click the Delete button on the toolbar.
2. Click Quantity (in light grey) at the upper left corner. 3. On the Query Studio menu, click Edit Data. 4. Click Sort: Sort...
5. In the Sort box, click Ascending (1-9). At the right side of the Sort box, make sure Based on group summaries is selected and Product type appears in the drop-down box. 6. Click OK. Your report will look like the one below, with the Product type summaries in ascending order:
the toolbar.
8. Type a name for your report. For the purposes of this class, type yourinitials followed by SortedCrosstab. (You may add a description of the report if you wish.) 9. Make sure the Option Button next to Public Folders > GO Sales and Retailers is selected and click OK. You may have to scroll down to see the OK button.
End of Exercise
24
Exercise 14Swap Rows and Columns 1. At the top right of the Cognos Query Studio window, click Return. 2. This takes you to the Cognos Connection Public Folders tab with your list of files. 3. Open the Crosstab Sales Territories report. 4. In the Crosstab Sales Territories report, click the Swap Rows and Columns button the toolbar. Your screen will look like the one below: on
5. Click Return at the top right or the window pane. When you are asked if you want to save the report, click No.
End of Exercise
Charts
Query Studio allows you to create charts to represent your data graphically. A chart must have at least one measure (quantitative data like Quantity, Revenue, etc.) and one non-measure (qualitative data like Product name, Country, etc.). When you create a chart, you can have a maximum of two non-measures. You can have as many measures as you want, but using too many will reduce the usefulness of your chart.
Types of Charts
Query Studio offers 7 types of charts and 4 ways to configure them: Chart Type Pie Chart Column Chart
Copyright 2008 RajivGupta
Definition A pie chart shows the relation of parts to the whole. It illustrates proportions rather than values. Pie charts can use standard, 100% stacked, and 3D configurations. A column chart compares individual values or illustrates data changes over time. Column charts can use standard, stacked, 100% stacked, and 3D 25
Bar Chart
Line Chart
Area Chart
Stacked Chart
100% Chart
3D Chart
configurations. A bar chart plots measures on the horizontal axis (in contrast to the usual vertical axis). Its main use is for comparing values. Bar charts can use standard, stacked, and 100% stacked configurations. A line chart shows trends over time. It uses data points connected by lines. When you pass the pointer over a data point, you see a box with the data details for the point. Line charts can use standard, stacked, 100% stacked, and 3D configurations. An area chart shows the magnitude of change over time or, when stacked, the relation of parts to the whole. Area charts can use standard, stacked, 100% stacked, and 3D configurations. A column line chart compares two different measures, placing a second quantitative axis at the right side of the chart. Column line charts can use standard, stacked, 100% stacked, and 3D configurations. A radar chart shows comparisons by combining multiple axes into one radial figure. It plots measures on each axis and connects them to adjacent axes using lines. Radar charts can use standard, stacked, 100% stacked, and 3D configurations. Definition Standard charts plot the value of each measure from a common baseline. Multiple measures appear in different colors on the chart. Stacked charts show the relative value of each measure to the total. Each measure appears as a different color in the stack. The top of the each stack represents the accumulated total of each measure. 100% stacked charts show the relation of each measure to the total, expressed as a percentage. Each measure appears as a different color in the stack. The top of the each stack represents 100%. 3D column, bar, area, and line charts plot measures in three dimensions. Pie charts have a three dimensional appearance.
Note: Creating a chart requires that you analyze your data to decide which chart type will best meet your needs. You may have to manipulate your data in some way to produce a useful chart. For example, if you want your chart to show percentages, your data must be expressed in percentages before you create the chart. Charts are created using the most summarized report data. For this reason, you should remove measures (quantitative data) that are not meaningful for your chart. You may also have to reorder your non-measure (qualitative data) columns. If your report contains grouped nonmeasures that you dont want in the chart, collapse the report before creating the chart.
26
You may have to pivot the chart (create a crosstab) to make it useful. (An example of this will be shown later in this class.) In the following exercise, you will create a new report and then create a chart using the data in the report. Exercise 15Create a Chart 1. At the top right of the window, click the Query Studio link to open a report: Query Studio 2. On the toolbar, click the New Report button to open a new report window pane.
3. In the Go Sales and Retailers package, expand the Countries item. 4. Click Sales Territory. Hold down the CTRL key, expand the Orders item and click Revenue. 5. Drag the selected items to the right window pane. 6. On the toolbar, click the Chart button to create a chart showing the revenue by sales territory. You will see a box like the one below:
7. From the drop-down box, select Pie. You will see the following options:
27
8. Click Standard. 9. On the right side of the box, click Show the values on the chart and Chart only. 10. Scroll down and click OK. You will see a chart that looks like the one below:
on the toolbar.
7. Type a name for your report: yourinitialsChartReport. (You may add a description of the report if you wish.) 8. Make sure the Option Button next to Public Folders > GO Sales and Retailers is selected and click OK. You may have to scroll down to see the OK button.
End of Exercise
In the next exercise, you will create a chart that requires some manipulation to show the results in a meaningful way. Your report will show the quantity of products sold by each order method in the years 2000, 2001, and 2002. You would like your chart to show the years on the x axis to illustrate changes in order methods over time.
2. In the Go Sales and Retailers package, expand the Orders item. 3. Click Order Year. Hold down the CTRL key, click Order Method and then click Quantity.
28
4. Drag the selected items to the right window pane. 5. On the toolbar, click the Chart button to create a chart showing the quantity of products sold in each of three years by sales order method. In the Chart box in the lower right window pane, make the choices as shown below:
6. Scroll down and click OK. You will see a chart like the following:
Notice that both Order year and Order method appear on the x axis and the results are not displayed in a clear way. You can manipulate the report so that the chart is more useful, and you can do that within the chart screen itself (if you selected Chart and table when you created the chart). 7. In the table below the chart, click the Order year heading to highlight the column. 8. On the toolbar, click the Pivot button to create a crosstab report. The chart will be redrawn and will look like the one below:
29
Now the chart shows the results more clearly, grouped by year and in an easier-to-read format. Note: If after you create a crosstab report, the chart still does not show the results you want, you can click Swap Rows and Columns to change the axis on which the non-measures will appear. 9. Click the Save As button on the toolbar.
10. Type a name for your report: yourinitialsPivotChart. (You may add a description of the report if you wish.) 11. Make sure the Option Button next to Public Folders > GO Sales and Retailers is selected and click OK. You may have to scroll down to see the OK button.
Filters
Earlier in this class, you created a filter to show product types sold only in Central, Northern and Southern Europe. When you did so, the resulting report contained a subset of your actual data. You can use filters on text, numeric, date and time data. If you filter quantitative data (measures), you can filter on the details (row by row data without summaries), on summaries (if your report contains summaries), and on individual records in the data source. In the following exercise, you will use the Grouped Product Types report you created earlier to filter quantitative data in the ways mentioned above. 30
Exercise 17Filter Measures 1. At the top right of the Cognos Query Studio window, click Return. On the Public Folders tab, you should see your list of files. 2. Open the Grouped Product Types report. 3. For the purpose of this exercise, first delete the Product name column from the report. Highlight the Product Name heading and click the Delete button .
First, you will filter on details in the report to see product types that had sales of quantities greater than 15,000 in the European sales territories. 4. Click the Quantity column heading, then click the Filter button the one below: . You will see a box like
5. Under Show only the following, type 15,000 in the From box. 6. Under Options, make sure Based on report details is selected. 7. Click OK. Your report window will look like the one below. Note that this is a sample of the data in your report. Page down to see the rest of the data.
31
Notice the additional filter subheading at the top of your report (Quantity: greater than or equal to 15000). The report now shows a subset of your original data, based on your filtering options. You will now change the report to filter on group summaries (shown in bold numbers at the bottom [footer] of each group). When you filter on summaries, you eliminate from the report any groups that dont meet your criteria. 8. On the toolbar, click the Undo button disappears. until the link for the filter you just added
9. Click the Quantity column heading, then click the Filter button
10. In the Filter box, under Show only the following, type 130,000 in the From box. 11. Under Options, select Based on group summaries. Make sure that Product type is selected in the drop-down box. 12. Click OK. Now your report window looks like the one below:
32
Notice the filter subheading at the top of your report (Quantity summary for Product type: greater than 130000). Only the Insect Repellents and Lanterns groups are listed in your report because their summaries for Quantity are greater than 130,000. You will now change the report to filter on individual records in the database. When you do this, you are filtering on the underlying data (e.g. each record for an insect repellant sold in Europe). Suppose you want your report to include only quantities between 25 and 100 for each product type. Filter in the following way: 13. On the toolbar, click the Undo button disappears. until the link for the filter you just added
14. Click the Quantity column heading, then click the Filter button
15. In the Filter box, under Show only the following, type 25 in the From box. 16. Type 100 in the To box. 17. Under Options, select Based on individual records in the database. 18. Click OK. Now your window looks like the one below:
Notice the filter subheading at the top of your report (Quantity raw values: between 25 and 100). If you compare the quantity of each product type with your original data, you will see that the number is smaller because this report retrieved only quantities between 25 and 100. Note: To remove a filter for a measure, delete all criteria in the Filter box.
End of Exercise
Use a Prompt
You can save time creating reports for which you want to use the same report item but different criteria. You do this by using a prompt. For example, in a report that shows the revenue for product types by country, you might want to generate reports for different groups of countries.
Copyright 2008 RajivGupta
33
Rather than create a new filter for each report, you can add a prompt to one filter. Each time the report runs, you are prompted for the values to include. In the following exercise, you will create a new report containing the revenue for product types by country. You will add a prompt to create several reports from the same data. Exercise 18Add a Prompt to a Filter 1. On the toolbar, click the New Report button to open a new report window pane. When you are asked if you want to save the report, click No. 2. In the Go Sales and Retailers package, expand the Products item. 3. Click Product type. 4. Hold down the CTRL key, expand the Countries item, and click Country. 5. Continue to hold down the CTRL key, expand the Orders item, and click Revenue. 6. Drag the selected items to the right window pane. 7. Click the heading of the Product type column to highlight it, then click the Group button . 8. Click the heading of the Country column to highlight it. 9. Click the Filter button . You will see a box like the one below:
10. Click the check box next to Prompt every time the report runs. 11. Scroll down and click OK. 12. On the toolbar, click the Run with All Data (and re-prompt) button like the one below: . You will see a box
34
13. In the Provide a value box, click China. 14. Hold down the CTRL key, scroll down and click Japan, Korea and Taiwan. 15. Click OK. Your report will now show revenue in Asia. 16. On the toolbar, click Run with All Data (and re-prompt) again. 17. This time, in the Provide a value box, click Australia; hold down the CTRL key, scroll down and click United Kingdom. Now the report shows revenue for those two countries. 18. Click the link for the filter (just above the report). In the resulting window, uncheck the box next to Prompt every time the report runs. This will remove the prompt from your filter, 19. Click Deselect all and click OK. This will remove the filter itself. 20. Click the Save As button on the toolbar.
21. Type a name for your report: yourinitialsRevenue. (You may add a description of the report if you wish.) 22. Make sure the Option Button next to Public Folders > GO Sales and Retailers is selected and click OK. You may have to scroll down to see the OK button.
End of Exercise
Custom Groups
In Query Studio, you might want to create a report that groups items in a way you define. For example, in your Revenue report, you might want to list the Asian countries under a heading called Asia and all other countries under a heading called Others. You can do this using the Define Custom Groups command in Query Studio. Note that you cant collapse a custom group report. In the following exercise, you will use the Revenue report to create a custom group.
Copyright 2008 RajivGupta
35
Exercise 19Create a Custom Group 1. In the Revenue report, click the heading of the Country column to highlight it. 2. On the Query Studio Edit Data menu, click Define Custom Groups. You will see a box like the one below:
3. In the New group name box, type Asia. 4. Click the green down-arrow to add the group name to Custom groups. 5. In the Available values box, click China; hold down the CRTL key, scroll down, click Japan, Korea and then Taiwan. 6. Click the green left-arrow to add the values to the Custom group values box. 7. In the New group name box, type Others. 8. Click the green down-arrow to add the group name to Custom groups. 9. In the Available values box, scroll to the bottom and click Remaining values (include future values). 10. Click the green left-arrow to add the values to the Custom group values box. 11. Scroll to the bottom of the Define Custom Groups box and click OK. Your report will look like the one below:
36
Any Asian country will appear in the Asia group, while all other countries will be listed as Others. You can remove the Country column to further refine the report to show revenue from Asia for each product in one row and from all other countries in a second row. 12. Click the heading of the Country column to highlight it and then click the Delete button . You now see the total Revenue for product types sold in Asia in one row and total revenue for all other countries in another. 13. Click the Save button to save the report.
End of Exercise
Data Formats
You can change the appearance of both textual and numeric data in your report without affecting the actual data. The possible formats are as follows: Format Default Number Action Data as it appears in the package. Remove any other formatting you add by selecting Default. Change the number of decimal places, include or remove a thousands separator, select symbols to represent negative numbers, and scale large numbers. Select from a list of world currencies and use either the currency symbol or international code notation. For example, the symbol for the United Kingdom pound is , and the international code is GBP. In addition, you can change the number of decimal places, include or remove a thousands separator, select symbols to represent negative numbers, and scale large numbers. Multiplies the number by 100, using two decimal places and a percent sign.. Shows a number in scientific notation, using exponents. 37
Currency
Percentage Scientific
Copyright 2008 RajivGupta
Select a date and time format from a list that includes date abbreviations and expansions.
Exercise 20Change Data Formats 1. On the toolbar, click the New Report button to open a new report window pane. If you are asked if you want to save the previous report, click Yes. 2. In the Go Sales and Retailers package, click Insert Data. 3. Expand the Products item and click Product type. 4. Hold down the CTRL key, click Product name and then click Introduction date. 5. Continue to hold down the CTRL key, expand the Orders item, and click Revenue. 6. Drag the selected items to the right window pane. 7. Click the heading of the Product type column, hold down the SHIFT key and click the heading of the Product name column to highlight both columns. 8. Click the Group button report items. on the toolbar to group the Product type and Product name
9. Click the heading of the Revenue column to highlight it. 10. On the menu, click Edit Data then click Format. You will see a Format box with a Category drop-down list. 11. From the Category drop-down list, select Currency. You will see a box like the one below:
12. From the Currency drop-down list, select (GPB) - United Kingdom, pound. 13. The Currency display drop-down list should show Currency symbol; Number of decimal places: 2; Scale: No scale; Negative sign: -123. From the Thousands separator drop-down list, select Yes.
Copyright 2008 RajivGupta
38
14. Click OK. The Revenue column will now show British pounds.
15. To see an example of formatting a date/time column, click the heading of the Introduction date column to highlight it. 16. On the menu, click Format and from the Category drop-down list, select Date. 17. From the Type box, select 12/19/03 and click OK. The date is now shown formatted with slashes. You can also format text columns to specify how many characters will appear in the column. For example, you might want to list only the first four letters of your sales representatives last names. To do this: 18. On the Insert Data menu, expand the Sales reps item. 19. Click Last name. Drag Last name into the report pane directly to the left of the Introduction date heading. When the column border becomes a bold, flashing line, release the mouse button. The Last name report item column now appears to the left of Introduction date. 20. Click the heading of the Last name column to highlight it. 21. On the Edit Data menu, click Format. From the Category drop-down list, select Text and in the Number of visible characters box, type 4; click OK. 22. After you finish the steps above, your report will look like the following:
Note that this is a sample of the data in your report. Page down to see the rest of the data. 23. Click the Save As button on the toolbar.
24. Type a name for your report: yourinitialsFormattedProducttype. (You may add a description of the report if you wish.)
Copyright 2008 RajivGupta
39
25. Make sure the Option Button next to Public Folders > GO Sales and Retailers is selected and click OK. You may have to scroll down to see the OK button.
End of Exercise
Calculations
Query Studio allows you to calculate report values using arithmetic, percentage, or analytic operations. You can perform calculations by adding either: Summaries The Summarize command adds or removes values in footers or changes how the detail rows are treated. You might create a summary to show the total number of different products for each product type your company sells. or Calculations The Calculate command adds a new report item using data from items already in your report. You might multiply two report columns (e.g., Quantity and Unit cost) to create a report item called Product cost. Summaries The options you can use when you click the Summarize command vary, depending upon the type of data you are summarizing. Possible options are:
Action Adds a set of values. Shows the total number of records for a report item. This is the only function available for text items. Shows the maximum value for the report item. If you select a date or time item, you will see the latest value. Shows the minimum value for the report item. If you select a date or time item, you will see the earliest value. Shows the average of the values in a report item. Removes footers for a report item.
Note: There is no notation added when you summarize a report to show that it is summarized. If you save a summarized report, and someone else opens it, they have no way of knowing that it actually contains summarized data rather than the totals shown when you first created the report. In the following exercise, you will use the Summarize command to find the average revenue for each product type for all countries.
40
Exercise 21Add a Summary to a Report 1. At the top right of the Cognos Query Studio window, click Return. On the Public Folders tab, you should see your list of files. 2. Open the Revenue report (the report will start with your initials). Notice the revenue totals in the detail and footer rows for the product types. 3. Click the heading of the Revenue column to highlight it. 4. On the Edit Data menu, click Summarize....
6. From the Summary for footers drop-down menu, select Average and click OK. The footers now show revenue averages for the product types (notice that the detail rows still show their original data). 7. Click the Save button to save the report.
Note: If you want to remove a summary, select None from the Summary for footers dropdown menu
End of Exercise
Advanced summaries You can also apply one summary calculation to detail rows and another to footers using the Advanced link at the top right of the Summarize command box (see above). In the following exercise, you will first add an Order number column to your Revenue report. You will then add a Count summary to the Order number detail rows and a Total summary to the footer rows to see how many order numbers were created for Asian countries, how many order numbers were created for all other countries, and how many were created overall. Exercise 22Add an Advanced Summary to a Report 1. In your Revenue report on the Query Studio menu, click Insert Data.
Copyright 2008 RajivGupta
41
2. Expand the Orders item and click Order number. 3. Drag Order number into the report pane directly to the left of the Country (Custom) heading. When the column border becomes a bold, flashing line, release the mouse button. The Order number report item column now appears to the left of Country (Custom). Notice that there is now an entry for each order number according to whether it originated in Asia or in Other. Page through the report to see this. To return the report to a more useful state, you can add summaries to the detail rows (order numbers) and total all the orders. 4. Click the heading of the Order number column to highlight it. Summarize....
6. When the Summarize box appears, click the Advanced link at the upper right. You will see a box like the one below.
7. From the Summary for cells drop-down box, select Count. 8. From the Summary for footers drop-down box, select Total. Click OK. Your report will look like the one below. Note that this is a sample of the data in your report. Page down to see the rest of the data.
42
Calculations When you perform a calculation on a report, Query Studio creates a new report item that shows the results of the calculation. Calculations can use data from one or several report items and offer different options, according to the operation you choose. You can either use the data that is already in the report or type another number in the Calculate boxs Number field. For example, you might want to multiply the quantity of products your company has sold by 1.25 to see how many youd have to sell to achieve a 25% increase. To carry out that calculation, you would type 1.25 into the Number field. Note: If the results of a calculation are not what you expected, you cant change the calculated report item. You must delete the newly created item and redo the calculation. Arithmetic Operations + (sum) - (difference) * (product) / (division) ^ (power) Absolute Action Adds report items you select. Subtracts one report item from another. Multiplies report items you select. Divides report items you select. Shows the exponent value of a report item. Shows the absolute value of the numbers in report items.
Rounds the values in a report item to the nearest integer. Rounds the values in a report item to the next lowest integer. Calculates the square root of the numbers in a report item.
Action Shows the value of a report item as a percentage of another report item. Shows each value of a report item as a percentage of the total. In a grouped report, shows each value as the percentage of the group total or the overall total. Shows the difference between two report items as a percentage.
% difference
Shows the largest of the values in a report item. Shows the smallest of the values in a report item. Ranks each value in a report item. In a grouped report, it can rank each value in a group or within all values. Shows each value in a report item as a percentage of the total. In a grouped report, it can show each value as the percentage of the group total or the overall total. Shows a percentile of values. In a grouped report, it can show the percentile for each value in a group or within all values. Shows the quartile of values. In a grouped report, it can show the quartile for each value in a group or within all values. Shows the quantile of values. In a grouped report, it can show the quantile for each value in a group or within all values. Note: A quantile is a general term for dividing a distribution into equal, ordered subgroups. For example, a quartile divides a distribution into quarters, a tercile divides it into thirds, and a centile divides it into hundredths.
In the following exercise, you will then perform a calculation to determine revenue for each product type according how it was ordered (order method). Additionally, you want to determine what the revenue would be if you multiply your unit cost by 1.25. Exercise 23Perform a Calculation on a Report 1. On the toolbar, click the New Report button to open a new report window pane. If you are asked if you want to save the previous report, click Yes. 2. On the Query Studio menu, click Insert Data. 3. Expand the Products item and click Product type. 4. Hold down the CTRL key, expand the Orders item and click Order method; continue to hold down the CTRL key and click Quantity and Unit cost. 5. Drag the selected items to the right window pane. 6. Click the Group button on the toolbar to group the Product type report item.
7. Click the heading of the Quantity column, hold down the SHIFT key and click the heading of the Unit cost column to highlight both columns. 8. On the menu, click Edit Data then click the like the one below: Calculate... command. You will see a box
44
9. Leave Operation type as Arithmetic. 10. From the Operation drop-down list, select * (product). 11. In the New item name box, type Revenue. Leave everything else as is, scroll down, and click Insert. After the report runs, you will notice that a Revenue columnthe result of your calculationhas been added to your report. The Revenue column needs to be formatted to be more understandable. 12. Click the heading of the Revenue column; then on the Edit Data menu, click Format. 13. From the Category drop-down list, select Number. When you see the Number options, select 2 for Number of decimal places and Yes for Thousands separator. Click OK. Your report should look like the one below. Note that this is a sample of the data in your report. Page down to see the rest of the data.
Next, you will perform a second calculation to determine revenue if you multiply your unit
Copyright 2008 RajivGupta
45
cost by 1.25. 14. Click the heading of the Quantity column, hold down the SHIFT key and click the heading of the Unit cost column to highlight both columns.
15. On the menu, click Edit Data then click the like the one in step 8 above. 16. Leave Operation type as Arithmetic.
17. From the Operation drop-down list, select * (product). 18. Click the radio button next to the Number box and type 1.25 in the box. 19. In the New item name box, type Revenue:Unitcost*1.25. Leave everything else as is, scroll down, and click Insert. After the report runs, you will notice that a Revenue:Unit cost*1.25 columnthe result of your second calculationhas been added to your report. 20. Click the Save As button on the toolbar.
21. Type a name for your report: yourinitialsCalculatedRevenue. (You may add a description of the report if you wish.) 22. Make sure the Option button next to Public Folders > GO Sales and Retailers is selected and click OK. You may have to scroll down to see the OK button.
End of Exercise
As part of using calculations in your report, you can concatenate text items into one column. In the following exercise, you will concatenate the Product type and Order method columns to form a single column. Exercise 24Concatenate Two Text Items 1. In the Calculated Revenue report, click the heading of the Product type column; hold down the SHIFT key and click the heading of the Order method column to highlight both columns. 2. From the Edit Data menu, click the one below: Calculate... command. You will see a box like the
46
3. From the Operation drop-down box, select Concatenation. The Calculate box will change to look like the following:
4. In the Separator between report items box, type a dash. Leave everything else as is and click Insert. You now have a new report item column: Product type-Order method. You can delete the two columns you used to create the concatenated report item. 5. Click the heading of the Product type column, hold down the SHIFT key and click the heading of the Order method column to highlight both columns. 6. Click the Delete button 7. Click the Save button on the toolbar to delete the columns. to save the report.
End of Exercise
More on Summaries and Calculations When you perform a calculation, Query Studios usual order is to summarize detail values first and then to calculate. There are a few exceptions to this rule: Detail rows If you perform a calculation on two or more columns with different types of detail summaries, the order changes to calculate first, then summarize.
Copyright 2008 RajivGupta
47
Footer rows If you perform a calculation on two or more columns with different types of detail summaries, the order changes to calculate first, then summarize. If you perform a calculation on a single column that is totaled and you have added a number to change the calculation, the order changes to calculate first, then summarize. For example, you might add 1.25 to the Number box to multiply the quantity of products your company has sold by 1.25.
Cognos Connection.
48