|
How to Create Word Reports
> Adding Formulas
Adding Formulas
OfficeWriter Enterprise Edition allows you to
create custom formulas. The formulas can be based on query
results, report parameters, or they may access a set of global variables that
Reporting Services contains. We will explore formulas by building a simple report
and then adding formulas. Please read the Quick Start
how to add queries and fields to reports if you do not already know how to do this.
This sample is based on the AdventureWorks sample database that is shipped with
Reporting Services.
- Open Microsoft Word and create a new document.
- Click OfficeWriter Designer's Add Query button.
- Follow steps 2-12 of
Create a Database Query in
Create Your First Word Report.
- In the Add Tables dialog box, find the SalesOrderHeader table in the
list and select Add. Click Close.
- Click the SQL button on the Microsoft Query toolbar, and enter the
following query:

- Click Ok.
- From the File menu, select Return to OfficeWriter
Designer.
Reporting Services Global Variables

Reporting Services contains global variables that you can access if you have
OfficeWriter Enterprise Edition. To access
the global variables:
- On the OfficeWriter toolbar, click Insert Formula and
select Build New Formula.
- In the Insert Formula dialog, click the + next
to Globals to open the list of Reporting Services global
variables.

You will see six global variables:
| Execution Time |
The report's execution time |
| Report Server URL |
The URL of the server running the report |
| Report Folder |
The folder on the Report Server containing the report |
| Report Name |
The Name of the report |
| User ID |
The ID of the user logged on |
| Language |
The report language |
- Select Execution Time from the list.
- Click Insert and Ok.
- At the top of your document, type Execution Time: followed by a space.
- Click Insert Formula and select =Globals!ExecutionTime.
The formula will be inserted in the document.
- Press Enter a few times to put some space between the formula and what
we will do next.
- Click Select Query on the OfficeWriter toolbar and
select the query created above.
- Insert a two-column, three-row table in the page.
- In the left column's first row, type Sales Person ID.
- In the right column's first row, type Sales Amount.
- Place your cursor in the second row of the left column.
- Select Insert Merge Field from the OfficeWriter toolbar and
choose SalesPersonID.
- Place your cursor in the second row of the right column.
- Select Insert Merge Field from the OfficeWriter toolbar and
choose SalesAmount.
- In the third row of the left column, type Total.

- Click Insert Formula on the OfficeWriter toolbar and select
Build New Formula.
- Click the + to expand the Formulas list.
- Scroll down, select SUM, and click insert.

- Click the + to expand the DataSets list.
- Find your query and click its + to open it.

- In the Expression list on the right, highlight everything
inside the SUM parentheses, as shown.

- Click SalesAmount and Insert. Your formula should now
look like this:

- Click Ok to return to your document.
- Place your cursor in the third row of the right column of your table.
- Select Insert Formula from the toolbar and choose your new
formula.

- Click Select Query on the OfficeWriter toolbar and select
your query.
- Highlight the second row of the table.

- Click Query Range on the OfficeWriter toolbar and make sure
Selection is chosen. Click Ok.
- Publish the report.
- Click View on the OfficeWriter toolbar. Your report should look
like this:
Managing Formulas

Officewriter Designer gives you the ability to manage and maintain
formulas you've built. The Formula Manager allows you to change,
delete, and build new formulas. To start the Formula Manager,
click the Insert Formula button on the OfficeWriter toolbar and select
Manage Formulas.

To build a new formula from the Formula Manager screen:
- Click the Add New... button. This will bring you
to the Formula Builder screen described in the previous section.
- Follow the directions above to create and use a new formula.
To change an existing formula:
- Highlight the formula you want to change.
- Click the Edit button. This brings you to the
Formulas Builder screen described above.
- Make the changes to the formula.
- Click Ok to save the updated formula.
To delete a formula:
- Highlight the formula you want to delete.
- Click the Delete button.
- Click Yes to confirm deletion.
- Click Close to return to the report document.
- Important: You must manually review your report document and
remove any reference to the deleted formula.
To rename a formula:
- Highlight the formula you want to rename.
- Click Rename.
- On the Formula Name screen, type in a new name and click Ok.

- Note: The formula name is only used to help you maintain formulas.
It is not used anywhere in your report document.

Copyright 2007 © SoftArtisans, Inc. All Rights Reserved.
|