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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Percent and Division by Zero Problem Please Help 2

Status
Not open for further replies.

Myla944

Technical User
Mar 4, 2004
24
US
Good Afternoon,

I am using Crystal Report 9 and MS SQL Database.

I am creating an Incident report that has these fields (manual cross-tab):

2004 2003 +/- Variance +/- Percent

Del Issues 55 55
Damage 78 22 56
Arrival Time 30 51 <21>

I created groups for the issues and then used the insert summary to sum the total of incidents for each year on the group lines. I used this formula:
({@CurrYear},{tblStoreReportSub.SubDesc}) - sum ({@LastYear},{tblStoreReportSub.SubDesc})
to get the variance,which worked great.

I am having a problem creating a formula to get the percentage variance for the last column.
First I tried this formula:
((@CurrYear),((tblStoreReportSub.SubDesc))%((@LastYear),((tblStoreReportSub.SubDesc)) and I get a divide by zero error because in 2003 there are null values.
Then I tried to do a IsNull formula, but that did not work either, so I am stumped.

I tried
If IsNull(@LastYear) then False
else ({@CurrYear})%({@LastYear})
this only showed zeros.

Please help! If you need more info please let me know.

Sincerely,
Myla
 
If (IsNull(@LastYear)= true or (@LastYear = 0.00) then 0.00
else ({@CurrYear})%({@LastYear})
 
Hello and Thanks,

I tried your formula, but it keeps showing an error on
THEN
maybe I am supposed to type something else? It keeps highlighting Then and saying "the ) is missing. I am confused. It did this same error message when I tried different variations of using the IsNull, this is driving me insane, ahhhh.

Sincerely,

Myla
 
If (IsNull(@LastYear)= true or (@LastYear = 0.00)) then 0.00
else ({@CurrYear})%({@LastYear})


oops - left out a right parenthesis just before the then
 
Try:

If IsNull({@LastYear}) or
{@LastYear} = 0 then 0
else {@CurrYear}%{@LastYear}

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top