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

calculation problem

Status
Not open for further replies.

izachar

Technical User
Oct 7, 2000
84
CA
I have a formula that takes out a field from a database under a condition

if {PM Unit Info.VACANT_INDICATOR}<>&quot;V&quot; then
numberVar occupied_sqf :={PM Unit Info.SQUARE_FEET}
else 0


Then I use it in another formula

if {@convert sqf to number}>0 then
Sum ({@ocx qf}, {PM Property Info.PROPERTY_NUMBER})/Sum ({@convert sqf to number}, {PM Property Info.PROPERTY_NUMBER})
*100


but if I have one record of {ocx qf}=0 then the second formula returns 0.00% which is wrong.

I know I can filter out the 0.00 using the select tool but I need to show them in the report.

Please help
 
Are you saying that a) the field {ocx qf}=0 or b) the group Sum({ocx qf},{Groupbyfield})=0 ?

If the summary is zero then of course 0/anything = 0 so the formula is returning the expected results.

If it is one individual record in the summary that = 0, and the summary itself is something other than zero, then I am clueless. Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
I would hange your formula to the following:

from:

********************** formula start ***************

if {PM Unit Info.VACANT_INDICATOR}<>&quot;V&quot; then
numberVar occupied_sqf :={PM Unit Info.SQUARE_FEET}
else 0

********************** formula end ***************


to:

********************** formula start ***************

numberVar occupied_sqf ;

if {PM Unit Info.VACANT_INDICATOR}<>&quot;V&quot; then
occupied_sqf := {PM Unit Info.SQUARE_FEET}
else
occupied_sqf := 0;

occupied_sqf;

********************** formula end ***************

this should work

Jim
 
Thank you Ngolem I see the reason why you changed the script but unfortunetaly it did not work. I ended up replaceing the second formula with:

numberVar total_sqf := cdbl(Sum ({@convert sqf to number}, {PM Property Info.PROPERTY_NUMBER}));

numberVar total_non_v:= cdbl(Sum ({@ocx qf}, {PM Property Info.PROPERTY_NUMBER}));

if total_sqf<>0 then

(total_non_v/total_sqf)*100

else

0


and it is now working. Strange but it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top