TAZI
asked on
NPER - (domain error occured)
Hi
Hilare assisted with the creation of a NPER Function that works similar to excel.
This is the NPER Function
create function NPERTEST(@rate float, @payment float,@capital float)
returns float
as
begin
return log10(@payment/(@payment+@ capital*@r ate))/log1 0(1+@rate)
end
go
select dbo.NPER(.203/12, 500, -5000) ---> returns 11.047592792208778
This works well and I haven't noticed a problem until this morning. Based on the value of the payment the procedure throws out a domain error occurred
Try this
Select dbo.NPERTEST(.203/12, 75, -5000) - Payment amount is R 75
Your urgent assistance is required
Thanks for your help in advance
Regards
TAZI
Hilare assisted with the creation of a NPER Function that works similar to excel.
This is the NPER Function
create function NPERTEST(@rate float, @payment float,@capital float)
returns float
as
begin
return log10(@payment/(@payment+@
end
go
select dbo.NPER(.203/12, 500, -5000) ---> returns 11.047592792208778
This works well and I haven't noticed a problem until this morning. Based on the value of the payment the procedure throws out a domain error occurred
Try this
Select dbo.NPERTEST(.203/12, 75, -5000) - Payment amount is R 75
Your urgent assistance is required
Thanks for your help in advance
Regards
TAZI
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
when (@payment+(@capital*@rate) ) is negative,
log10(@payment+(@capital*@ rate)) can't be computed
using microsoft's algorithm ...
best I can do is return a default value (eg 0) when a correct NPER can't be computed
create function NPERTEST(@rate float, @payment float,@capital float)
returns float
as
begin
return case
when @payment+@capital*@rate < 0 then 0
else log10(@payment/(@payment+@ capital*@r ate))/log1 0(1+@rate)
end
end
go
log10(@payment+(@capital*@
using microsoft's algorithm ...
best I can do is return a default value (eg 0) when a correct NPER can't be computed
create function NPERTEST(@rate float, @payment float,@capital float)
returns float
as
begin
return case
when @payment+@capital*@rate < 0 then 0
else log10(@payment/(@payment+@
end
end
go
Yet a default value of 0 might generate more errors if you use this NPER in other calculations,
so maybe another dummy value like 9999999 would be better.
Anyway you'll have to handle this care somewhere in your code and alert the user on the fact that NPER can't be computed with these parameters values
so maybe another dummy value like 9999999 would be better.
Anyway you'll have to handle this care somewhere in your code and alert the user on the fact that NPER can't be computed with these parameters values
i meant "handle this case"
ASKER
Hi Hilare
Thank you so much for your help.
I did the following to overcome the problem. I work out the minimum payment that a debtor can make against his outstanding debt and if the amount that the debtor wants to pay is less then mimimum payment I know I am going to get an error and return out of the procedure with the minimum value. I then display this on screen informing the collector that he/she has to capture a value greater then the minimum payment.
Thanks anyway for your help.
It is greately appreciate.
I will assign the 50 points to you .. you deserve it with all the help that you've given me with these procedures.
Thanks
Regards
TAZI
Thank you so much for your help.
I did the following to overcome the problem. I work out the minimum payment that a debtor can make against his outstanding debt and if the amount that the debtor wants to pay is less then mimimum payment I know I am going to get an error and return out of the procedure with the minimum value. I then display this on screen informing the collector that he/she has to capture a value greater then the minimum payment.
Thanks anyway for your help.
It is greately appreciate.
I will assign the 50 points to you .. you deserve it with all the help that you've given me with these procedures.
Thanks
Regards
TAZI
ASKER
Thanks a million for your prompt response.
How would this be handled then. I didn't test it in Excel, but have been bothered by it all morning.
Basically, the procedure is being used in an Debt Collection Environment. In the example above, the Debtor owes R5000.00 and the interest rate is 20.3%. If the debtor wants to pay R 75.00 per month, how would we determine the number of periods then.
The payment amount is dynamic ... one does not know how much the debtor wants to pay.
Thanks for your help in advance
Regards
TAZI