How to include natural log (ln) in query

G

Guest

I want to calculate the following expression in a query, where LN is the
natural log function.

10-((LN(Sum([sciPercentTolerantTaxa])+1))/4.1)*10)

I get an error message saying that LN is undefined. Does Access not compute
LN(x)? The LOG(x, base) function works in my expression, but I don't want to
use Log10 (the default) or an approximate base "e" for natural log.

Is VBA my only option? I'm trying to avoid it if I can.
Thanks
 
K

Ken Snell [MVP]

VBA's Log function is the natural logarithm.

From ACCESS Help File:

Log Function
Returns a Double specifying the natural logarithm of a number.

Syntax
Log(number)

The required number argument is a Double or any valid numeric expression
greater than zero.

Remarks
The natural logarithm is the logarithm to the base e. The constant e is
approximately 2.718282.
You can calculate base-n logarithms for any number x by dividing the
natural logarithm of x by the natural logarithm of n as follows:
Logn(x) = Log(x) / Log(n)

The following example illustrates a custom Function that calculates
base-10 logarithms:
Static Function Log10(X)
Log10 = Log(X) / Log(10#)
End Function
 
G

Guest

Thank you for this information. However, in my Access 2000 Help file, the
only reference to the LOG function is the following:

"LOG
Returns the logarithm of a number to the base you specify.
Syntax
LOG(number,base)
Number is the positive real number whose logarithm you want.
Base is the base of the logarithm; 10 if omitted."

There is a separate entry for the LN worksheet function. These do seem to
be more applicable to Excel worksheets than Access SQL, but I cannot find any
reference to an SQL LOG function that gives the natural log. I double
checked my formula, and you are correct, it is returning the natural log. Is
there an error in my Access Help files?

Thanks.


Ken Snell said:
VBA's Log function is the natural logarithm.

From ACCESS Help File:

Log Function
Returns a Double specifying the natural logarithm of a number.

Syntax
Log(number)

The required number argument is a Double or any valid numeric expression
greater than zero.

Remarks
The natural logarithm is the logarithm to the base e. The constant e is
approximately 2.718282.
You can calculate base-n logarithms for any number x by dividing the
natural logarithm of x by the natural logarithm of n as follows:
Logn(x) = Log(x) / Log(n)

The following example illustrates a custom Function that calculates
base-10 logarithms:
Static Function Log10(X)
Log10 = Log(X) / Log(10#)
End Function

--

Ken Snell
<MS ACCESS MVP>


kraymond said:
I want to calculate the following expression in a query, where LN is the
natural log function.

10-((LN(Sum([sciPercentTolerantTaxa])+1))/4.1)*10)

I get an error message saying that LN is undefined. Does Access not
compute
LN(x)? The LOG(x, base) function works in my expression, but I don't want
to
use Log10 (the default) or an approximate base "e" for natural log.

Is VBA my only option? I'm trying to avoid it if I can.
Thanks
 
K

Ken Snell [MVP]

Methinks you're reading information from an EXCEL Help file, not ACCESS help
file. Everything that you've noted (LOG, LN, LOG10, etc.) are in the EXCEL
help file, not ACCESS help.

You should be able to use the VBA function named Log in queries to get the
natural logarithm of a value.

--

Ken Snell
<MS ACCESS MVP>



kraymond said:
Thank you for this information. However, in my Access 2000 Help file, the
only reference to the LOG function is the following:

"LOG
Returns the logarithm of a number to the base you specify.
Syntax
LOG(number,base)
Number is the positive real number whose logarithm you want.
Base is the base of the logarithm; 10 if omitted."

There is a separate entry for the LN worksheet function. These do seem to
be more applicable to Excel worksheets than Access SQL, but I cannot find
any
reference to an SQL LOG function that gives the natural log. I double
checked my formula, and you are correct, it is returning the natural log.
Is
there an error in my Access Help files?

Thanks.


Ken Snell said:
VBA's Log function is the natural logarithm.

From ACCESS Help File:

Log Function
Returns a Double specifying the natural logarithm of a number.

Syntax
Log(number)

The required number argument is a Double or any valid numeric expression
greater than zero.

Remarks
The natural logarithm is the logarithm to the base e. The constant e
is
approximately 2.718282.
You can calculate base-n logarithms for any number x by dividing the
natural logarithm of x by the natural logarithm of n as follows:
Logn(x) = Log(x) / Log(n)

The following example illustrates a custom Function that calculates
base-10 logarithms:
Static Function Log10(X)
Log10 = Log(X) / Log(10#)
End Function

--

Ken Snell
<MS ACCESS MVP>


kraymond said:
I want to calculate the following expression in a query, where LN is the
natural log function.

10-((LN(Sum([sciPercentTolerantTaxa])+1))/4.1)*10)

I get an error message saying that LN is undefined. Does Access not
compute
LN(x)? The LOG(x, base) function works in my expression, but I don't
want
to
use Log10 (the default) or an approximate base "e" for natural log.

Is VBA my only option? I'm trying to avoid it if I can.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

LOG vs LOG10 1
Natural log function 1
USING LOG and LN 1
How do I get a natural logarithm, Access forms, it's LN in excel 3
Update Query... How to? 1
How to fit a "ln" function 2
Problems with LN in VBA 1
Access Query problem 1

Top