The ATAN2 function in Google Sheets returns the angle in radians between the positive x-axis and a line from the origin to a point (x, y). Its syntax is =ATAN2(x, y), where x is the x-coordinate and y is the y-coordinate. Unlike the single-argument ATAN function, ATAN2 uses the signs of both arguments to determine the correct quadrant of the angle, so it returns a value between -π and π (approximately -3.14159 to 3.14159). This makes it useful for calculating bearings, directions, and angles in geometry, navigation, and engineering. To use it, you only need a Google account and access to Google Sheets; no add-ons or special setup are required.
What You'll Need
- A Google account (free).
- Access to Google Sheets via a web browser or the mobile app.
- Two numeric values (x and y coordinates) or cell references containing them.
Step-by-Step
- Open Google Sheets. Go to sheets.google.com and open a new or existing spreadsheet.
- Select an empty cell. Click the cell where you want the result to appear.
- Type the ATAN2 formula. Start with an equals sign, then type
ATAN2(. For example:=ATAN2(1, 1). - Enter the x-coordinate first. The first argument is the x value (horizontal distance). You can type a number directly or click a cell that contains the x value. For instance, if A1 holds 1, type
=ATAN2(A1,. - Enter the y-coordinate second. After a comma, type or click the y value (vertical distance). Complete the formula with a closing parenthesis. Example:
=ATAN2(A1, B1)where A1 is x and B1 is y. - Press Enter. The cell will display the angle in radians. For
=ATAN2(1, 1), the result is approximately 0.7853981634 (π/4 radians). - Convert to degrees if needed. Wrap the formula in the DEGREES function:
=DEGREES(ATAN2(A1, B1)). This returns the angle in degrees (45 for the example above). - Copy the formula down. Drag the fill handle (small square at the bottom-right of the cell) to apply the formula to other rows, adjusting cell references automatically.
- Format the result. Use the toolbar to increase or decrease decimal places, or apply a custom number format if you want a specific display.
Common Mistakes
- Swapping x and y. ATAN2 expects the x-coordinate first, then y. Reversing them gives the complementary angle (reflected across the line y = x), which is often wrong for your use case.
- Using ATAN instead of ATAN2. ATAN takes only one argument (y/x) and cannot distinguish quadrants; it returns values only between -π/2 and π/2. Use ATAN2 when you need the full range.
- Forgetting parentheses. Missing a closing parenthesis causes a formula parse error. Google Sheets may suggest a correction; accept it only if it matches your intent.
- Passing text instead of numbers. If a referenced cell contains text (even numeric-looking text with spaces), ATAN2 returns a #VALUE! error. Ensure cells are formatted as numbers or use VALUE() to convert.
- Expecting degrees. ATAN2 returns radians. If you need degrees, wrap it in DEGREES() as shown above.
- Both arguments zero.
=ATAN2(0,0)returns 0 in Google Sheets, but mathematically the angle is undefined. Avoid using (0,0) in calculations that require a direction.
Tips
- Use cell references for dynamic results. Instead of hardcoding numbers, reference cells so the angle updates automatically when coordinates change.
- Remember the order: x then y. A simple mnemonic: "x comes before y in the alphabet," matching the argument order.
- Convert to a compass bearing. To get a bearing measured clockwise from north (0° to 360°), use
=MOD(DEGREES(ATAN2(x, y)), 360)or adjust based on your coordinate system. Test with known points to confirm orientation. - Combine with other functions. Use ATAN2 with SQRT and POWER to compute polar coordinates: radius =
=SQRT(x^2 + y^2), angle ==ATAN2(x, y). - Check for radians vs degrees in charts. If you plot angles, ensure the chart axis is set to the correct unit or convert values beforehand.
Troubleshooting
- #VALUE! error: One or both arguments are non-numeric. Check the referenced cells for text, blank spaces, or formatting. Use
=ISNUMBER(A1)to test. Convert text to numbers with=VALUE(A1)or reformat the cell. - #N/A error: A referenced cell is empty or contains an error. Ensure all referenced cells have valid numbers.
- Wrong angle (off by 90° or 180°): You likely swapped x and y, or your coordinate system defines axes differently. Double-check the expected order and sign conventions for your application.
- Formula not calculating: Ensure the cell is not formatted as plain text. Select the cell, go to Format > Number > Automatic or Number.
- Unexpected 0 result: If both arguments are 0, ATAN2 returns 0. Verify your inputs are not both zero unless intended.
- If that did not work: Try re-entering the formula manually, or test with simple numbers like
=ATAN2(1,1)to confirm the function works in your sheet. If the issue persists, check Google Sheets' calculation settings (File > Settings > Calculation) to ensure iterative calculation is off, which can affect some formulas.
Frequently Asked Questions
What is the difference between ATAN and ATAN2?
ATAN takes a single argument (y/x) and returns an angle between -π/2 and π/2. ATAN2 takes two arguments (x, y) and returns an angle between -π and π, correctly identifying the quadrant based on the signs of both coordinates.
Does ATAN2 return degrees or radians?
It returns radians. To convert to degrees, wrap the formula in the DEGREES function: =DEGREES(ATAN2(x, y)).
Can I use ATAN2 with negative coordinates?
Yes. ATAN2 handles negative values and returns angles in the correct quadrant. For example, =ATAN2(-1, -1) returns approximately -2.356 radians (-135°).
What happens if both arguments are zero?
Google Sheets returns 0 for =ATAN2(0,0), though the angle is mathematically undefined. Avoid using (0,0) when a direction is needed.
Is ATAN2 available in the Google Sheets mobile app?
Yes, the function works the same in the Android and iOS apps. You can type the formula manually or use the function list.
How do I get a compass bearing from ATAN2?
Use =MOD(DEGREES(ATAN2(x, y)), 360) for a bearing measured clockwise from north, but verify the orientation with a known point because conventions vary by field.