Creating reports

From Apache OpenOffice Wiki
< Documentation‎ | OOo3 User Guides‎ | Getting Started
Revision as of 03:07, 12 October 2008 by Jeanweber (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Reports provide information found in the database in a useful way. In this they are similar to queries. Reports are generated from the database's tables or queries. They can contain all of the fields of the table or query or just a selected group of fields. Reports can be static or dynamic. Static reports contain the data in the selected fields at the time the report was created. Dynamic reports can be updated to show the latest data.

For example, a report on vacation expenses divided into categories should probably be a static report because it is based upon specific data that does not change. However, a report on the fuel data should probably be a dynamic report, because this report depends upon data that does change.

Documentation caution.png All reports are based upon a single table or query. So you need first to decide what fields you want to use in the report. If you want to use fields from different tables, you must first combine these fields in a single query. Then you can create a report on this query.

An example of this caution is creating a report on vacation expenses. Fuel costs are one part of that report as are meal costs. These values are contained in fields of two different tables: Vacations and Fuel. So this report requires creating a query.

Top of page

Creating a static report

We will create a report on vacation expenses. Certain questions need to be asked before creating the report.

  • What information do we want in the report?
  • How do we want the information arraigned?
  • What fields are required to provide this information?
  • Will a query have to be created because these fields are in different tables?
  • Are there any calculations required in the data before being added to the report?

The expenses for our vacation are motel, tolls, miscellaneous, breakfast, lunch, supper, snacks, and fuel. One possible report would simply list the totals of each of these expense groups. Another possible report would list the expense totals for each day of the vacation. A third possible report would list the totals for each expense group for each type of payment. (This would let us know where the money came from to pay the expenses.) At the present time, using the data from the queries in a spreadsheet is the best way to handle reports like this. In the near future, the report feature will include these abilities.

For our purposes, we will create two reports. The first one will list the expenses each day other than fuel. The second report will list the fuel costs each day.

The fields we will need for the first report from the Vacations table are: Date, Motel, Toll, Breakfast, Lunch, Supper, SnackCost, and Miscellaneous. This report will not require an additional query.

The second report involves the Fuel table. Since fuel was purchased and entered into this table at times other than during the vacation, a query needs to be created that contains only the fuel purchased during the vacation.

Top of page

Vacations table report

  1. Create a new report.
    1. Click the Reports icon in the Database list in the Automobile - OpenOffice.org window.
    2. In the Tasks list, click Use Wizard to Create Report. The Report Wizard window opens.
  2. Select the fields.
    1. Select Table: Vacations in the Tables or Queries dropdown list.
    2. Use the > to move these fields from the Available fields list to the Fields in report list: Date, Motel, Tolls, Miscellaneous, Breakfast, Lunch, Supper, and SnackCost. Click Next.
    3. Adding fields to a report.
  3. Label the fields.
    Shorten Miscellaneous to Misc. Click Next.
  4. Group fields.
    Since we are grouping by the date, use the > button to move the Date field to the Grouping list. Click Next.
  5. Grouping list
  6. Sort options.
    We do not want to do any additional sorting. Click Next.
  7. Choose layout.
    We will be using the default settings for the layout. Click Next.
  8. Template:Documentation/Note

  9. Create report.
  10. Label the report: Vacation Expenses.
  11. Select Static report.
  12. Click Finished.

Top of page

Vacation fuel report

  1. Create a query containing only fuel bought on the days of the vacation.
    1. Open a query in Design View.
    2. Follow the steps for adding tables in Step 2. Add tables of Using the Design View to create a query. Add the Fuel table.
    3. Double-click these fields in the Fuel table listing: Date and FuelCost to enter them in the table at the bottom of the query.
    4. In the Criterion cell of the Date field, type the following:
    5. BETWEEN #5/25/2007# AND #5/26/2007#
      Setting the criterion for a query.
    6. Save, name, and close the query. (Suggestion: Vacation Fuel Purchases.)

    Template:Documentation/Tip

  2. Open a new report.
    1. Right-click the Vacation Fuel Purchases query.
    2. Select Report Wizard from the context menu.

    Template:Documentation/Note

  3. Create the report.
    Use >> to move both fields from the Available Fields to the Fields in Report list. Click Next.
  4. Label fields.
    Add a space to FuelCost to make it Fuel Cost (two words). Click Next.
  5. Group fields.
    1. Click Date to highlight it.
    2. Use > to move the Date field to the Groupings list. Click Next.
  6. Choose layout.
    We will be making no changes in the layout. Click Next.
  7. Create report (final settings).
    1. Use the suggested name, which is the same as the query.
    2. Select Static report. Click Finish.

Top of page

Creating a dynamic report

We will create a report with some statistics on our fuel consumption. To do this, we have to modify two queries: End-Reading and Fuel Economy. We will be adding the FuelCost field to the End-Reading query. Then we will add the FuelCost field from the End-Reading query to the Fuel Economy query.

Template:Documentation/Tip

Appearance of query when opened for editing.
  1. Add the FuelCost field to the End-Reading query:
    1. Right-click the End-Reading query and select Edit from the context menu.
    2. In the Fuel table list, double-click to add FuelCost to the bottom table.
    3. Save and close the query.
    4. Adding an additional field to the query.
  2. Add the FuelCost field from the End-Reading query to the Fuel Economy query.
    1. Right-click the Fuel Economy query and select Edit from the context menu.
    2. Double-click the FuelCost field in the End-Reading query list to the table at the bottom.
  3. Add a calculation field to the right of the FuelCost field.
    1. Type the following in the Field cell:
      "End-Reading".FuelCost/("End-Reading".Odometer - Fuel.Odometer)
    2. Type the following in the Alias cell:
      cost per mile

    Template:Documentation/Note

  4. Save and close the query.
  5. Open a new report.
    Right-click the Fuel Economy query and select Report Wizard.
  6. Select fields.
    Move all the fields from the Available fields to the Fields in report list. Use the >> to do so. Click Next.
  7. Label fields.
    Change FuelCost to Fuel Cost by placing a space between the words. Click Next.
  8. Group fields.
    Use > to move the Date field to the Groupings list. Click Next.
  9. Sort options: the wizard skipped this one.
  10. Choose layout.
    Accept the default. Click Next.
  11. Create the report.
    1. Change the report name to Fuel Statistics.
    2. The default setting is Dynamic report, so no change is necessary.
    3. Select Modify report layout. Click Finish.

Top of page

Modifying a report

At the end of the last section, we left the Fuel Statistics report open in the edit mode. We will be working on that report. These same steps can be used with any report that you open for editing.

A report in edit mode.

The Author is the name you listed in Tools > Options > OpenOffice.org > User Data. The date is not correct. The columns need to be moved to the left to give a better appearance. None of the numbers are correct, but their only purpose is to show the number of decimal places.

Top of page

Step 1: Change the date.

  1. Click to the right of the date (4/26/20) so that the cursor is next to the field. Use the Backspace key to erase the date.
  2. Insert > Fields > Date. This places today's date where the original date was.
  3. Change the date formating:
    1. Double-click the date field you just inserted. The Edit Fields: Document window opens (Figure 91).
    2. Figure 91: Modifying a date field.
    3. Since this is a dynamic report, change the Select field from Date (fixed) to Date.
    4. Change the Format to what you desire. (I use the Friday, December 31, 1999 choice.) Click OK.

Top of page

Step 2: Change the column widths.

The column widths can be changed by moving the cursor over the right border of each column so that it becomes a double-headed arrow. Then drag and drop it where you want it. This has to be done for each column in each table in the report. This can also be done with the last column on the right even though there is no black border. It should now look something like the figure below.

Realigned columns in a report.

Top of page

Step 3: Change the number formating in the cells.

The fuel quantity should have three decimal places. The Begin, End, and Distance should have one decimal place. Fuel Cost should be currency and have two decimal places, and Cost per mile should have three decimal places.

  1. Right-click the cell below Quantity to open the context menu. (The cell is circled in red in the figure above.)
  2. Select Number format.
  3. In the Options section,
    1. Change the number of Decimal places to 3.
    2. Click the green checkmark. Click OK.
    3. Option section of the Number Formating window.
  4. Change the Fuel Cost field.
    1. Right-click in the cell below Fuel Cost.
    2. Select Number Format.
    3. In the Category list, select Currency. Click OK.
  5. Change the Cost per mile field.
    1. Right-click in the cell below Cost per mile.
    2. Select Number Format.
    3. In the Category list, select Currency.
    4. In the Option section:
      • Set the number of decimal places to 3.
      • Click the green checkmark.
    5. Click OK.

Top of page

Step 4: Save and close the report.

Double-click the report. It should now look like the figure below.

Final report.

Top of page

Content on this page is licensed under the Creative Common Attribution 3.0 license (CC-BY).
Personal tools