×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Calculating a value in the SUBTOTAL

## Calculating a value in the SUBTOTAL

(OP)
I have a report which requires SUBTOTALS.

The problem starts with the third column which is calculated based off of the 1st and 2nd SUBTOTALS.

Example:

SUBTOTAL_A        SUBTOTAL_B       CALCULATED_VALUE
55                75                26.66%

Formula is:
((SUBTOTAL_B - SUBTOTAL_A)/SUBTOTAL_B) * 100

Can this be done in the Subtotal area?

Thanks,

Leo

### RE: Calculating a value in the SUBTOTAL

DEFINE FILE CAR
SUBA/I6 = 55;
SUBB/I6 = 75;
END

TABLE FILE CAR
PRINT SUBA
SUBB
COMPUTE PCT/D6.2 = ((SUBB - SUBA)/SUBB) * 100;
BY COUNTRY
ON COUNTRY RECOMPUTE
ON COUNTRY SUB-TOTAL
IF RECORDLIMIT EQ 5
END

Returns

PAGE 1

COUNTRY SUBA SUBB PCT

ENGLAND          55  75 26.67
*TOTAL ENGLAND   55  75 26.67
FRANCE           55  75 26.67
*TOTAL FRANCE    55  75 26.67
ITALY            55  75 26.67
*TOTAL ITALY     55  75 26.67
JAPAN            55  75 26.67
*TOTAL JAPAN     55  75 26.67
W GERMANY        55  75 26.67
*TOTAL W GERMANY 55  75 26.67
*TOTAL W GERMANY 55  75 26.67
TOTAL           275 375 26.67

Is that what you were looking to do?

### RE: Calculating a value in the SUBTOTAL

(OP)
It appears like what i am trying to do, but I will have many detail records before the subtotals.

I'll try it and let you know.
Thanks.

Thanks,

Leo

### RE: Calculating a value in the SUBTOTAL

(OP)
In other words, the PCT field should be calculated from the SUBTOTALS; not the detail records.

Thanks,

Leo

### RE: Calculating a value in the SUBTOTAL

(OP)
The above code calculated the values for each row, but it's showing the total of the PCT column instead of showing the computed field as the PCT subtotal.

Thanks,

Leo

### RE: Calculating a value in the SUBTOTAL

On the SUBTOTAL line ('ON field ...') do you say SUBTOTAL or SUB-TOTAL, which adds up the COMPUTEd field, or RECOMPUTE/SUMMARIZE, which redoes the calculation, based on subtotaled values?

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!