|
How to Create Excel 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
SQL Server Reporting Services 2005.
- Open Microsoft Excel.
- Click OfficeWriter Designer's Add Query button.
- Follow steps 2-11 of
Create a Database Query in
Create Your First Excel Report.
- In the Add Tables dialog box, find the Sales.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.
- Click Insert Formula and select Build New Formula.
- Expand the Globals list.
- Select Report Server URL from the list.
- Click Insert and Ok.
- Repeat the steps above until you have added all six
global variables. When you select Insert Formula, you should see:

- In cell A1, type Execution Time.
- Place your cursor in cell B1, click Insert Formula, and select
=Globals!ExecutionTime. The formula will be inserted in cell B1.
- Type labels for each of the other variables (as in step 10) and
insert each formula after its label.

- Click Select Query on the OfficeWriter toolbar and
select the query created above.
- In cell A8, type Sales Person ID.
- In cell B8, type Sales Amount.
- Place your cursor in cell A9, select Insert Field
from the OfficeWriter toolbar and choose SalesPersonID.
- Place your cursor in cell B9, select Insert Field
from the OfficeWriter toolbar and choose SalesAmount.
- In cell A10, 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 worksheet.
- Place your cursor in cell B10, select Insert Formula from
the toolbar and choose your new formula.

- 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.
|