Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula help - Display ** for values less than -999 or high than +999 2

Status
Not open for further replies.

kutoose

Technical User
Sep 11, 2002
169
US
Environment

Crystal Reports 10
Oracle 9


Hi
I am calculating percentage difference
in a report. The formula I am using is

If Sum ({TranPrev}, {Group1}) = 0
then 0
else
(Sum ({TranCurr}, {Group1})-
Sum ({TranPrev}, {Group1}))%
Sum ({TranPrev}, {Group}1)

Now in the same formula I need to limit
the result from -999 to + 999.
That is if the percentage diff is -999 to +999
then show that value else show "***".

How can I achieve this ?


kutoose@yahoo.com
 
Try:

If Sum ({TranPrev}, {Group1}) = 0
then "0" else
if (
(Sum ({TranCurr}, {Group1})-Sum ({TranPrev}, {Group1}))%
Sum ({TranPrev}, {Group1}) < -999 or
(Sum ({TranCurr}, {Group1})-Sum ({TranPrev}, {Group1}))%
Sum ({TranPrev}, {Group1}) > 999
) then "***" else
totext(((Sum ({TranCurr}, {Group1})-Sum ({TranPrev}, {Group1}))% Sum ({TranPrev}, {Group1}),0,"")//change "0" to whatever
//number of decimals you want

-LB
 
This might make it simpler to read:

Local NumberVar n := Sum ({TranCurr}, {Group1}) ;
Local NumberVar d := Sum ({TranPrev}, {Group1}) ;
Local NumberVar r := 0 ;
If d = 0 then r := 0 else
r := (n-d) % d ;

if Abs(r) > 999 then "***" else (ToText(r)& " %")




Bob Suruncle
 
Thank You - Bob and lbass. Both worked !


kutoose@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top