Number.Atan2

Number

Returns the angle in radians between the positive x-axis and the point (x, y), correctly handling all four quadrants.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Number.Atan2(y as nullable number, x as nullable number) as nullable number

Parameters

NameTypeRequiredDescription
ynumberYesThe y-coordinate (vertical component).
xnumberYesThe x-coordinate (horizontal component).

Return Value

numberThe angle in radians in the range (-π, π].

Remarks

Number.Atan2(y, x) computes the angle θ (in radians) between the positive x-axis and the point (x, y). The result is in the range (-π, π]. This is the two-argument form of the arctangent that correctly handles all four quadrants by considering the signs of both x and y independently.

Critical: the parameter order is y first, then x. This is the standard mathematical convention and matches how ATAN2 works in Excel. A common mistake is reversing the arguments — Number.Atan2(x, y) will give the wrong angle for any non-symmetric point.

The advantage over Number.Atan(y/x) is quadrant correctness: for the point (-3, -4), y/x = 4/3 and Number.Atan(4/3) gives ~53°, but the correct angle is ~−127° (third quadrant). Number.Atan2(-4, -3) correctly returns ~−127°. Additionally, Number.Atan2 handles the case x = 0 without division-by-zero — it returns ±π/2 depending on the sign of y.

To convert the radian result to degrees, multiply by 180 / Number.PI. All Power Query M trigonometric functions work in radians, not degrees.

Examples

Example 1: Angle to the point (1, 1) — 45 degrees

Number.Atan2(1, 1) * 180 / Number.PI
Result
Result
145

Example 2: Angle to a negative-x point (180 degrees)

Number.Atan2(0, -1) * 180 / Number.PI
Result
Result
1180

Example 3: Compute bearing angle in degrees to a 2D coordinate

let
    X = 3,
    Y = 4,
    AngleDegrees = Number.Atan2(Y, X) * 180 / Number.PI
in
    AngleDegrees
Applied Steps

The final output — the bearing angle in degrees from the positive x-axis to the point (3, 4).

Result
153.13

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks