Google Sheets Log Formula: How to Calculate Logarithms
In this article
To calculate a logarithm in Google Sheets, use the formula =LOG(value, [base]). This function returns the logarithm of a number based on a specified base; if the base is omitted, Google Sheets defaults to base 10. This is essential for analyzing data that grows exponentially, such as sound intensity, earthquake magnitude, or financial compound growth.
What You'll Need
- A Google account with access to Google Sheets.
- A dataset containing the positive numbers you wish to analyze.
- A basic understanding of which logarithmic base you require (e.g., base 10 for common logs, base 2 for binary logs, or base e for natural logs).
Step-by-Step
- Open your Google Sheet: Navigate to your browser and open the specific spreadsheet where you want to perform the calculation. Ensure your data is organized in columns or rows for easier formula application.
- Identify your Value: Determine which cell contains the number you want to find the logarithm of. For example, if your data point is in cell A2, this will be your "value" argument. Note that the value must be a positive number; logarithms of zero or negative numbers are mathematically undefined and will result in an error.
- Select your Base: Decide which base you are using. If you are performing a common logarithm (base 10), you can leave the base argument blank. If you need a specific base, such as base 2 for computing or base 5 for a custom scale, have that number ready.
- Enter the Formula: Click on the empty cell where you want the result to appear. Type
=LOG(. - Input the Arguments:
- Click on the cell containing your value (e.g., A2).
- Type a comma.
- Either type the number for the base (e.g., 2) or click on a cell that contains the base value.
- Close the parenthesis:
).
=LOG(A2, 2). - Execute the Calculation: Press Enter. Google Sheets will immediately display the exponent to which the base must be raised to produce the value in A2.
- Apply to Multiple Rows: To apply this calculation to an entire column of data, click the small blue square (the fill handle) in the bottom-right corner of the cell containing your formula and drag it down through the rest of your data range. Google Sheets will automatically adjust the cell references (e.g., A2 becomes A3, A4, etc.).
Common Mistakes
One of the most frequent errors is attempting to calculate the logarithm of a negative number or zero. Because there is no power to which a positive base can be raised to produce a negative number or zero, Google Sheets will return a #NUM! error. Always ensure your source data is filtered for positive values before applying the formula.
Another common mistake is confusing the LOG function with the LN function. While LOG allows you to specify any base, LN is specifically designed for the natural logarithm (base e, approximately 2.718). While you can achieve a natural log using =LOG(value, EXP(1)), using the dedicated LN function is more efficient and reduces the chance of typing errors.
Users also frequently forget the comma between the value and the base. If you type =LOG(A2 B2) without the comma, Google Sheets will return a formula parse error because it cannot distinguish between the two arguments. Ensure the syntax strictly follows the (value, base) format.
Finally, some users enter the base as the first argument and the value as the second. The LOG function is not commutative; the value you are analyzing must always come first, followed by the base. Reversing these will lead to mathematically incorrect results that may go unnoticed if the user is not checking the output against expected values.
Tips
To make your spreadsheet more dynamic, place your base value in a single, dedicated cell (e.g., cell C1) and use an absolute reference in your formula. Instead of typing =LOG(A2, 10), use =LOG(A2, $C$1). The dollar signs lock the reference to cell C1. This allows you to change the base for your entire dataset simply by changing the number in one cell, rather than editing every single formula in the column.
If you are working with very large datasets, consider using an ARRAYFORMULA. Instead of dragging the fill handle down thousands of rows, you can wrap your log function like this: =ARRAYFORMULA(LOG(A2:A100, 10)). This will calculate the logarithm for the entire range A2 through A100 in one go, keeping your sheet cleaner and reducing the risk of accidental formula deletions in individual cells.
For those visualizing data, remember that logarithmic scales are incredibly useful for charts. If your data spans several orders of magnitude (e.g., some values are 10 and others are 1,000,000), a standard linear chart will squash the smaller values against the axis. By creating a new column of logarithmic values using the LOG formula and charting those instead, you can see the relative change across all data points more clearly.
Troubleshooting
If your formula is not working, first check for the #NUM! error. As mentioned, this almost always means your input value is zero or negative. Check your source cells for hidden zeros or negative signs. If the data is imported from another source, ensure there are no non-numeric characters (like currency symbols or spaces) that might be causing Google Sheets to treat the number as text.
If you see a #VALUE! error, it means one of the arguments is not a number. Check that you haven't accidentally selected a header row or a cell containing a word. Ensure that both the value and the base are formatted as "Number" in the Format > Number menu.
If the result seems mathematically incorrect, double-check your base. A common point of confusion is the difference between base 2 and base 10. For example, =LOG(8, 2) equals 3, but =LOG(8, 10) equals approximately 0.903. Ensure you are using the base required for your specific field of study.
If the formula returns a long string of decimals that is difficult to read, use the "Decrease decimal places" button in the toolbar (the .00 with the left arrow). This doesn't change the actual value stored in the cell, but it makes the spreadsheet much more readable for presentations or reports.
Frequently Asked Questions
What is the difference between LOG and LN in Google Sheets?
The LOG function allows you to specify any base you want (or defaults to 10), whereas the LN function is strictly for the natural logarithm, which uses the constant e as its base.
Can I use a decimal as a base in the LOG formula?
Yes, you can use decimals as a base (e.g., =LOG(10, 1.5)), provided the base is a positive number and not equal to 1. A base of 1 is mathematically invalid because 1 raised to any power is always 1.
Why does my LOG formula return an error when the cell is empty?
Google Sheets may treat an empty cell as zero. Since the logarithm of zero is undefined, it triggers a #NUM! error. You can wrap your formula in =IFERROR(LOG(A2, 10), "") to leave the cell blank if an error occurs.
How do I calculate a log base 2 specifically?
You can either use the general formula =LOG(value, 2) or use the specialized =LOG2(value) function, which is a shorthand specifically for binary logarithms.
Does the LOG formula work with cell references for both arguments?
Yes. You can use =LOG(A2, B2) where A2 is the value and B2 is the base. This is highly useful for creating tables where you compare different bases across the same set of values.