Computes and Defines: The Best of Both Worlds
By Geneviève Monet
Until now WebFOCUS users could use computes only by creating them inside of a report. In WebFOCUS 7.1.3, Information Builders is adding support for computes in master file descriptions.
Wait a minute, how can that work? That was the first question that came to my mind. Soon, I thought of other questions that may also come to the minds of other WebFOCUS users.
Some of you also may wonder what is the difference between these new computes and the defines that already are in master file descriptions. Others may ask, Why would we want to do that?
So let's start by looking at how WebFOCUS produces a report to see why defines and computes are really quite different. In a nutshell, there are three main steps to produce a WebFOCUS report. Here is what happens:
- WebFOCUS transfers data to an internal
storage area much like a spreadsheet called internal matrix. During this step, WebFOCUS does the following:
- Selects data from the data source using selections that test fields that already exist in the database (
WHERE and IF).
- Calculates defines on each record (
DEFINE).
- Further selects data using selections that test these defined fields (
WHERE and IF).
- Sorts, aggregates and transfers the selected data to the internal matrix (
BY, SUM).
- WebFOCUS processes the data in the internal matrix. During this step, these things occur:
- Computed fields are calculated, along with prefix operators (
COMPUTE).
- Data is selected from the internal matrix using selections that test computed field, prefix operators or aggregated data (
WHERE TOTAL).
- Data is sorted based on computed field, prefix operators or aggregated data
(
BY TOTAL)
- WebFOCUS produces the report and applies formatting and styling:
- Places headings, footing and titles (
HEADING).
- Calculates group totals (
SUBTOTAL).
Look at Figure 1 for an illustration.
Figure 1

So defines and computes can be very different because of when they occur in the processing. Because a compute is calculated on aggregated, sorted data it is often more efficient. A define is calculated on every single selected record but sometimes this is necessary as in testing an anniversary.
Defines are also much easier to format and manipulate in the user interface for report creation. Another thing to keep in mind is that the result of a calculation can be slightly different because of rounding depending on whether it is calculated on each record, rounded and summed or calculated directly on the summed data, and then rounded.
With WebFOCUS 7.1.3, it will be possible to issue a compute, once and for all, inside the MFD. But how will it work? I have found out that these MFD computes will still be handled the same way, during the processing of the internal matrix. Also, if a selection or a sort is made with the computed field, WebFOCUS will know that it needs to generate a WHERE TOTAL or a BY TOTAL.
So, by adding this new feature, we will give users the efficiency of computes plus the added convenience of being able to simply drag and drop the computed field when creating a report much like a define. And that is the best of both worlds!
|