How to calculate a logarithm in Excel
Formula (Excel and Google Sheets)
=LOG(A2,B2)Use LOG with the base as the second argument, =LOG(A2,B2); LOG10 is base 10 and LN is the natural log.
- Result on the example
- one result per row in
C2, filled down toC6 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in C2, filled down to C6. Change any input and the result updates, or edit the formula to experiment.
How it works
A logarithm answers "what power of the base gives this value?". 10³ = 1,000, so LOG(1000,10) is 3; 2⁶ = 64, so LOG(64,2) is 6. Values below 1 give negative logs: 0.01 is 10⁻². A fractional result like 2.5 means 4^2.5 = 32.
=LOG(A2,B2)Result3
A21000The value in A2.
B210The value in B2.
LOG(A2,B2)3LOG: Logarithm, base 10 by default.- number
A21000 - base
B210
- number
In Google Sheets
The same formula works in Google Sheets: =LOG(A2,B2). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =LN(A2)/LN(B2) | 3, 6, 4… | The change-of-base rule: any log is the natural log of the value divided by the natural log of the base. |
Common mistakes
- LOG without a base is base 10, not the natural log many calculators and programming languages use. For base e, use LN.
- The logarithm of 0 or a negative number returns #NUM!.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Calculate a logarithm
C2, calculate the logarithm of the value in A2 to the base in B2, then fill down to C6.Questions
How do I calculate log base 2?
Use =LOG(A2,2).
How do I undo a logarithm?
Raise the base to the result: =B2^C2, or =10^C2 and =EXP(C2) for base 10 and natural logs.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.