Click to See Complete Forum and Search --> : Simple math issue
Matt_T_hat
Jul 22nd, 2004, 04:01 AM
I have a database that supplies numbers for some math.
The math is of the form A plus B over C
A + B
------
C
However sometimes C is 0.
Therefore I need a formula that will work normally for all values greater than nothing but result in 0 when C is 0. Is this do able?
Thanks guys. :afrog:
manavo11
Jul 22nd, 2004, 04:15 AM
Have a system :
A+B
C , for C>0
0 , for C=0
Matt_T_hat
Jul 22nd, 2004, 04:53 AM
Originally posted by manavo11
Have a system :
A+B
C , for C>0
0 , for C=0 I was hopeing that there was some formula with a bit of +1, -1 etc that would simply by pass div by zero... I hate editing the raw SQL as it is nested six selects deep.
Ecniv
Jul 22nd, 2004, 05:06 AM
You'll need an equivalent of iif (instant if).
iif(c=0,0,(a+b/c))
either that or put the formula into a sub query with a linkable ID filtered on the c<>0.
Vince
Matt_T_hat
Jul 22nd, 2004, 07:43 AM
Originally posted by Ecniv
You'll need an equivalent of iif (instant if).
iif(c=0,0,(a+b/c))
either that or put the formula into a sub query with a linkable ID filtered on the c<>0.
Vince Probably yes. I don't want to face what access does to nested queries when you open them back up... but yes at least you have illiminated non-options.
Something Else
Jul 22nd, 2004, 06:31 PM
Hmmm,
Well:
(1\(C+1)) + C
Results in 1 if C = 0, or C when C > 0.
But you now need a multiplier that = 0 when C = 0, or 1 when C <> 0.
Hmmm,
K = (1\(C+1))+C
So,
When C = 0, then K = 1
When C > 0, then K = C
So:
C/K = 0 when C = 0,
C/K = 1, when C > 0.
Therefore:
(C/K)*(A+B)/(K)
where
K = (1\(C+1))+C
hmmm,
Is that Right?
:wave:
-Lou
Matt_T_hat
Jul 26th, 2004, 03:34 AM
Looks hopefull
Matt_T_hat
Jul 26th, 2004, 08:06 AM
I loved the math however smarty pants in the office next door may have jsut shown us all up "why not simply ignore all values of 0 and never use it as +0 and 0 not added is the same"
beasty!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.