# How to calculate a logarithm in Excel

Use LOG with the base as the second argument, `=LOG(A2,B2)`; LOG10 is base 10 and LN is the natural log.

**Excel:** `=LOG(A2,B2)` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C |
| --- | --- | --- |
| Value | Base | Logarithm |
| 1000 | 10 |  |
| 64 | 2 |  |
| 81 | 3 |  |
| 0.01 | 10 |  |
| 32 | 4 |  |

Formula in C2, filled to C6: `=LOG(A2,B2)`

Result: 3; 6; 4; -2; 2.5

## 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.

## Other ways

- `=LN(A2)/LN(B2)`: 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!.

## 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.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/calculate-a-logarithm
