View Full Version : % calc in report problem


Mike Hughes
02-29-2004, 07:19 AM
I use the following to determine the % of current paid of the current owed.

=([CURRENT PAID]/[CURRENT OWED])*100

This works fine...but when there is no data in the current paid and current owed fields I get some type of formula in the place where, I would think, 0 or an empty field should go. I can't see the entire entry because the field is too narrow.
(Some of the Paid and Owed fields are either empty(null) or contain $0.00)

Can someone tell me how to either have the % field come up empty or with a 0 when there is a record with no data to create the % amount or when the data in the fields is $0.00.

With the help of another I have also tried this:

=IIF([CURRENT OWED])=0,0,IIF([CURRENT PAID])=0,0,nz([CURRENT PAID])/nz([CURRENT OWED])*100)))

But I get this error when I try to use this one: "The expression you entered has a function containing the wrong number of arguments "

chappy
02-29-2004, 10:53 AM
It looks like there are three unnecessary closing brackets in your iif() statement that are causing the error, I put them in bold:

=IIF([CURRENT OWED])=0,0,IIF([CURRENT PAID])=0,0,nz([CURRENT PAID])/nz([CURRENT OWED])*100)))

so you're iif() statement should be:

=IIF([CURRENT OWED]=0,0,IIF([CURRENT PAID]=0,0,nz([CURRENT PAID])/nz([CURRENT OWED])*100))


hope that helps.

-Chappy

Mike Hughes
02-29-2004, 10:58 AM
It works great! One last question while I have you on the line.

How can this now be used where I have a sum field, like these?

=Sum([CURRENT PAID]) or =Sum([CURRENT OWED])

Now I need to figure the % of the sum of the current paid for all workers and the sum of the current owed for all the workers.

Can this be done with your formula and what would it look like?

Thanks

chappy
02-29-2004, 11:12 AM
"Now I need to figure the % of the sum of the current paid for all workers and the sum of the current owed for all the workers. "

I believe you can calculate that with the following formula:

=Sum([Current Paid])/Sum([Current Owed]) * 100

The sum() function might have a problem with null values, however I'm not certain of this. If it does, then you may want to run a quick query to zero any null values you have in your data table.

Hope this helps!

-Chappy

Mike Hughes
02-29-2004, 12:35 PM
That worked, I think...there still seems to be a small problem with the format. Please see attachment.

chappy
03-01-2004, 03:53 AM
Unfortunately I don't have access to a Windows machine right now, so I can't view the example file you posted, however if you enclose the function in a format() function, then you can have the results display however you want. To get them to display as a percentage (% sign and all), you can type the following:

=format(sum([Current Paid])/sum([Current Owed]),'Percent')

click here (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctformat.asp) for the Microsoft reference on the format function.

Hope this helps.

-Chappy