To calculate a logarithm in Excel, use LOG: with the value in A2 and the base in B2, enter =LOG(A2,B2). For a base-10 logarithm, use LOG10; for a natural logarithm, use LN. A logarithm answers the question “what power gives this number?” For example, the log of 100 with base 10 is 2 because 10 squared equals 100.
What You’ll Need
- Microsoft Excel for Microsoft 365 on Windows. The LOG, LOG10, and LN functions also work in Excel for Mac and Excel for the web, though the menus and window layout may differ.
- A number greater than zero whose logarithm you want to calculate. For a custom base, you also need a base greater than zero and not equal to 1.
- A worksheet cell for the result. You can enter a number directly in a formula or refer to cells containing your inputs.
Logarithms are useful for reversing exponentiation, comparing values that span a wide range, and working with formulas in science, statistics, and data analysis. Excel calculates the result for you; the important part is choosing the correct base and checking that the input is valid.
Step-by-Step
- Identify the number and the base. In a logarithm, the number is the value whose logarithm you want, and the base is the number being raised to a power. For example, log base 2 of 32 asks “2 to what power equals 32?” The answer is 5, since 2⁵ = 32. If the task does not name a base, check the surrounding instructions: base 10 is common in many school and engineering problems, while natural logarithms use base e.
- Enter the number and, if needed, the base. For a reusable worksheet, put the value in A2 and the base in B2. For example, enter 32 in A2 and 2 in B2. Keeping inputs in separate cells makes it easy to change the values and reuse the calculation. If you have a list, put each value on its own row and keep the base in a consistent column or cell.
- Calculate a logarithm with a custom base. With the value in A2 and the base in B2, enter
=LOG(A2,B2)in C2 and press Enter. With 32 in A2 and 2 in B2, the result is 5. LOG takes the number first and the base second. You can also enter fixed values directly: with no cell inputs needed,=LOG(32,2)returns 5. For a series of rows, copy the C2 formula down; Excel adjusts relative references for each row. - Use base 10 when that is the required base. With 100 in A2, enter
=LOG10(A2)in B2. Excel returns 2, because 10² = 100. LOG10 is a clear choice when the question specifically asks for a common logarithm. LOG can also calculate the same result: with 100 in A2, enter=LOG(A2,10)in B2. If the base is omitted from LOG, Excel assumes base 10; with 100 in A2,=LOG(A2)returns 2. Writing the base explicitly can make a formula easier for someone else to interpret. - Use LN for the natural logarithm. The natural logarithm has base e, approximately 2.71828. With e² in A2 (approximately 7.389056), enter
=LN(A2)in B2. The result is approximately 2. LN does not take a base argument. Do not substitute LOG or LOG10 when instructions specifically call for a natural logarithm; those functions use base 10 unless you set another base with LOG. - Use a logarithm to find an unknown exponent. If an equation is written as base raised to an unknown power equals a value, take the logarithm of the value using that base. For example, with 81 in A2 and 3 in B2, enter
=LOG(A2,B2)in C2. Excel returns 4, which solves 3 raised to x = 81. This works because a logarithm is the inverse operation of exponentiation. If the base is not supplied as a cell value, enter the known values directly;=LOG(81,3)returns 4. - Check and format the result. Compare the answer with the original question and, where possible, verify it by raising the base to the result. For the 32 and 2 example, the answer 5 checks because 2⁵ = 32. Logarithms can be whole numbers, decimals, or negative numbers: for instance, with 0.01 in A2,
=LOG10(A2)returns -2 because 10 raised to -2 is 0.01. If Excel displays too many decimal places, select the result cell and use Home > Number to choose a number format or adjust decimal places. Formatting changes what is displayed, not the underlying result.
These functions also work when you type them directly into a formula bar or a worksheet cell. In Excel for Mac, enter the same function names and arguments; the formula syntax is the same. Excel for the web also supports these functions, although its ribbon arrangement can differ from the Windows desktop app.
Common Mistakes
- Using the wrong base. LOG with no base means base 10, not base e. Use LN for base e, LOG10 for base 10, or give LOG a second argument for another base. A wrong base can produce a plausible-looking but incorrect result, so check the wording of the problem.
- Reversing the arguments. In LOG, the first argument is the number and the second is the base. With 32 in A2 and 2 in B2,
=LOG(A2,B2)returns 5. Reversing the inputs attempts to find the logarithm of 2 with base 32, which is a different calculation. - Trying to use zero or a negative number. Real-valued logarithms are defined only for positive numbers. Zero and negative inputs cause Excel to return an error. A very small positive number is allowed and can produce a negative answer; that is not the same as a negative input.
- Choosing an invalid base. A base must be positive and cannot equal 1. A base of 1 never changes when raised to any power, so it cannot produce a unique logarithm. Check both the number and base cells if LOG returns an error.
- Confusing the result with the original value. A logarithm is an exponent, not another version of the input number. If the result is 3 for base 10, that means the original value is 10³, or 1,000.
Tips
- Label input columns clearly, such as “Value,” “Base,” and “Log result.” This helps prevent accidentally swapping the number and base when formulas are copied or shared.
- Use cell references rather than repeatedly typing different values into formulas. A formula based on A2 and B2 can be filled down a table, and later changes to the inputs update the results automatically.
- Decide how many decimal places your work requires. Keep enough precision for later calculations; reducing displayed decimals with number formatting does not round the stored result.
- For a quick reasonableness check, raise the base to the calculated logarithm. The result should be close to the original positive number. Tiny differences can occur because Excel stores and displays numbers with finite precision.
- If you are following a textbook or a software procedure, match its stated convention. “Log” often means base 10 in school contexts, but some mathematical and programming contexts use other conventions. LN specifically identifies the natural logarithm in Excel.
Troubleshooting
Excel shows #NUM!. Check that the number is positive. If you used LOG with a custom base, also confirm that the base is positive and is not 1. A value of zero or less cannot produce a real-valued logarithm, and a base of 1 is not valid.
Excel shows #VALUE!. One or more inputs may be text rather than numbers. Look for values such as “100 ” with an extra space, text labels in an input cell, or numbers imported as text. Re-enter the input as a number, or use a cell that contains a numeric value. If a formula refers to a blank or text cell, check that the reference points to the intended input.
The result is not what you expected. Confirm the argument order and base. With a value of 100 and base 10, the answer is 2; if you wanted a natural logarithm, use LN instead. Test the calculation with a small known example, then compare the formula’s cell references with the cells containing your actual data.
The formula appears as text instead of calculating. The cell may be formatted as Text, or the entry may begin with an apostrophe. Change the cell format to General, then edit the formula and press Enter again. Also verify that the formula begins with an equals sign and that calculation has not been interrupted by accidentally typing a leading apostrophe.
You see a rounded result or a long decimal. Adjust the displayed number of decimal places from the Home tab, or use an appropriate number format. Do not change the input just to make the displayed answer look tidy. If a later formula depends on the result, retain the full underlying precision unless the instructions specifically require rounding.
Frequently Asked Questions
What is the difference between LOG, LOG10, and LN?
LOG calculates a logarithm with a chosen base; if you leave the base out, it uses 10. LOG10 always uses base 10. LN uses the natural base e.
How do I calculate log base 2 in Excel?
Use LOG with 2 as the second argument. With the value in A2, enter =LOG(A2,2). For example, if A2 contains 8, the result is 3 because 2³ = 8.
Can a logarithm be negative?
Yes. A positive input between 0 and 1 has a negative logarithm when the base is greater than 1. For example, the base-10 logarithm of 0.1 is -1. The input itself must still be positive.
Why does LOG return an error for zero?
There is no real number you can raise a positive base to that produces zero. Excel therefore cannot return a real-valued logarithm for zero. Check whether zero is a valid data value for your task rather than replacing it automatically.
Can I use LOG functions in Excel for Mac or the web?
Yes. LOG, LOG10, and LN use the same function names and formula syntax in current Excel for Mac and Excel for the web. The interface may look different, but you can enter the formulas in a cell as usual.
Related
- Daily Cash Flow Template Excel: How to Build and Use It
- Daily Cleaning Checklist Template Excel: Setup Guide
- Daily Cash Flow Report Template in Excel: Setup and Use
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Filter Multiple Criteria in One Column: How It WorksTo filter one Excel column for several allowed values, select the column’s filter arrow and check each value…
- SUMIFS Won’t Work: Causes and FixesSUMIFS usually fails because its ranges do not line up, its criteria do not match the values in…
- How to Calculate ROI Percentage in Excel With a FormulaTo calculate return on investment (ROI) in Excel, subtract the investment cost from its final value, divide the…
- Excel SUMIF Criteria Examples for Text, Dates, and NumbersExcel’s SUMIF function adds values when one matching condition is true. With categories in A2:A7 and amounts in…
- COUNTIFS Excel Formula: Multiple Criteria and ExamplesUse Excel’s COUNTIFS function to count rows that meet two or more conditions: =COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...).…
- Excel Formula to Add Dates in SequenceTo add dates in sequence in Excel, enter a starting date in A2, then enter =A2+1 in A3…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.