What is happening in this " PIC" and without the "PIC"?

Ohmes, Matt Matt.Ohmes@COGNOS.com
Mon, 3 Apr 2000 10:48:06 -0400


Hi Valerie,

I agree with Chris Sharman that your "percentage" looks a little funny to
me. 3.18% is not technically right.  But I'll put that aside for the moment
and discuss your problem.

The size in the Defined item does not necessarily restrict the size of the
expression, but rather it defines how much "space" you have to store the
item in the record complex.  Change it to be at least 5, but that is not the
confusing part to most people. Everyone seems to misunderstand picture
clauses; particularly related to calculations involving division.

It might help to remember a few of the "oddities" of how PowerHouse handles
calculations and pictures.

FIRST: When a number (calculation result or not, but you usually see this
effect on division operations) the number is rounded to a whole number
before it is acted upon by the picture clause.  In your first calculation
below:
760,000 / 2,389 * 100 = 31812.47  This number is rounded to 31812 (for
DISPLAY purposes only!), then the picture clause layered across it. Since
you physically Rounded the result, there is no fractional portion, but we
would round for display anyway.  Physical Rounding does help get you the
"right" results if you Subtotal a column of calculated numbers. For example,
10/3 = 3.33333...  If you display them, you see "3", but if you add a column
of 3 of them, you get a subtotal of 10! (3.3333... + 3.33333... + 3.33333).
If you round them first then subtotal, you get the subtotal result of 9,
what the user expects.

SECOND: The picture clause is just a dumb mask!  It does not effect the
internal number in any way. The caret (^) is the number substitution
character. Every other character in the picture is just printed as shown,
unless you run out of significant digits.
With the number you started with (31812.47), here are some pic results.
pic "^^^^^^"   " 31812"
pic "^^^.^^"   "318.12"
pic "^XX^^^^"  "3XX1812"
pic "^,^^^.^^" "  318.12" (note, leading pic characters are dropped when we
run out of significant leading digits)
pic "^"        #       (not enough carets to display all digits)
pic "^^.^^"    #####   (same result. This was your pic.)

THIRD: Output Scale only effects the displayed number, not the internally
stored number.  You could use Output scale to attack your problem, but I
think this usually only confuses people.  I usually just recommend
performing a calculation that gives the number of digits you want.

Now, knowing this, I suggest one of two options:
* Change your picture clause to include at least 5 carets (i.e. "^^^.^^").
This will let you see 318.12.
* If you want to see 3.12 instead, then don't multiply by 100. 
  760,000 / 2,389 = 318.12 -> 318 rounded -> 3.18 with a pic of "^^.^^"

If you want a % sign at the end, just add it to the pic "^^.^^%"

Hope that helps,
Matt 8-)

Matt.Ohmes@Cognos.Com
Cognos Corporation
909 E. Las Colinas Blvd.
Suite 1900
Irving, TX  75039
214-259-6200
"Matt doesn't really know anything.  He just likes to pontificate a lot.
We refuse to acknowledge that he works for Cognos or that we have ever
met him or anyone with whom he's ever been associated.  Don't lend him
money and don't let him talk to your sister!" ;-)


-----Original Message-----
From: Scott, Valerie
To: powerh-l@lists.swau.edu
Sent: 3/31/00 6:15 PM
Subject: What is happening in this " PIC" and without the "PIC"?

We have a item def as num*4, it is the receiver of the result of a
computation, and then should be displayed as a percent of that result.
we have tested it several ways as you will see below, but we are baffled
by
the results:
-The resultant value in our example is larger than the defined size of
the
item
-If we do not specify a pic in the Report statement, it will display the
value although because of no formatting, there is no way for the
audience to
know it is a percent
-if we use a pic, then we get an overflow error
How can we display the value properly as "3.18"?

Thank you,

Valerie Scott
>SET DIC DD011101.DOC.SCIPS
> ACC B41301-COMMINDST
> SET REP LIMIT 1000
> DEFINE ACTUALGRM NUM*4 = ROUND ((ADJPRICE / AGI) * 100)
> SORT ON GRM
> REP SALEAPN ADJPRICE AGI GRM ACTUALGRM ACTUALGRM PIC "^^.^^"
> SEL IF ACTUALGRM > 9999
> GO

00/03/31 PAGE   1

  Parcel Number   Adjusted Price  Annual Gross  G.R.M.  ACTUALGRM
ACTUALGRM
                                     Income

   0089372250            760,000        2,389    3.18     31812
#####

Records selected:  1
Records sorted:    1
Lines printed:     4
Pages printed:     1

>SEL IF SALEAPN = "0113490070"
> GO

00/03/31 PAGE   1

  Parcel Number   Adjusted Price  Annual Gross  G.R.M.  ACTUALGRM
ACTUALGRM
                                     Income

   0113490070            820,400       63,760   12.86      1287
12.87
Records selected:  1
Records sorted:    1
Lines printed:     4
Pages printed:     1

<snip>
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
This list is closed, thus to post to the list, you must be a subscriber.