IBM Support

Web Query - DEFINE and COMPUTE

Troubleshooting


Problem

Web Query has two ways to define a user generated field. This document discusses the difference, provides an example, and references the Web Query RedBook for more information.

Resolving The Problem

Web Query has two ways to define a user generated field. This document discusses the difference, provides an example, and references the Web Query RedBook for more information

IBM DB2 Web Query for IBM i - The Nuts and Bolts (SG24-8379)

There are two types of calculated fields in Db2 Web Query, DEFINE and COMPUTE.

When you use the DEFINE field, you add the definition to the list of fields within the table. This field is calculated every time that a record is read and selected.

When you create a COMPUTE field, the field is not calculated until after the data is sorted and all aggregation is complete.
COMPUTE fields are often required for percentages and variances.


This example shows the difference between Web Query's DEFINE and COMPUTE.

Result of running a Web Query report that has both a DEFINE and a COMPUTE

The red arrows show the DEFINE and the blue arrows the COMPUTE.


Notice that for DEFINE, the percent column is merely added together (133.3 + 137.8 + 217.3 = 488.4 (rounding)), generating a percent value that does not make sense. That is because a COMPUTE field is what is required in this example.  (3045 / 2160 * 100)
 

Example of DEFINE
 

DEFINE_example

Example of COMPUTE
 

COMPUTE_example
- make sure your break on Order Number is Recomputed

Subtotal_Recomputed

 

Any arithmetic calculation that uses an INTEGER for a result data type is truncated and not rounded



 

[{"Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m50000000Cac4AAC","label":"IBM i WebQuery->Report Development"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Version(s)"}]

Historical Number

N1010784

Document Information

More support for:
IBM i

Component:
IBM i WebQuery->Report Development

Software version:
All Version(s)

Operating system(s):
IBM i

Document number:
684149

Modified date:
20 November 2020

UID

nas8N1010784

Manage My Notification Subscriptions