Power Query Number.ATan: How to Use It
In this article
Power Query's Number.ATan function returns the arctangent of a number — the angle in radians whose tangent equals that number. The result is always between -π/2 and π/2 (roughly -1.5708 to 1.5708). To use it, open the Power Query Editor, add a custom column or step, and call Number.ATan(yourNumber). That's the whole answer. The rest of this guide covers exact syntax, how to convert the result to degrees, how to handle nulls and errors, and the mistakes that trip people up.
What You'll Need
- Excel (Microsoft 365, Excel 2021 or later) with Power Query, or Power BI Desktop. The function is also available in Power Query Online and in dataflows.
- A table or column of numeric values loaded into the Power Query Editor.
- Basic familiarity with the Power Query Editor: the ribbon, the Queries pane, and the formula bar.
- Optional: a calculator or the
Number.PIfunction if you want to convert radians to degrees.
Step-by-Step
- Load your data into Power Query. In Excel, select your table and go to Data > From Table/Range. In Power BI Desktop, use Home > Transform data to open the Power Query Editor. Menu labels can differ slightly by version, device or region.
- Confirm the column is numeric. Click the column header. If the icon shows ABC or a text symbol, go to the Home tab and use Data Type > Decimal Number (or Whole Number).
Number.ATanexpects a number; text values will produce an error. - Add a custom column. On the Add Column tab, click Custom Column. Give it a name such as AngleRadians.
- Enter the formula. In the Custom Column dialog, type
Number.ATan([YourColumn]), replacing[YourColumn]with the exact name of your numeric column. Column names are case-sensitive in M and must be enclosed in square brackets. - Check the result. Click OK. Power Query adds the new column and shows a preview. For example,
Number.ATan(1)returns about 0.7854 (π/4 radians). - Convert to degrees if needed. Radians are the native output. To get degrees, wrap the call:
Number.ATan([YourColumn]) * 180 / Number.PI. For 1, that returns 45. - Handle nulls and errors. If your column can contain nulls, guard the call:
if [YourColumn] = null then null else Number.ATan([YourColumn]). This keeps the column clean instead of producing errors. - Rename and set the data type. Right-click the new column header, choose Rename, then set its data type to Decimal Number so downstream steps treat it as numeric.
- Apply and close. In Excel, use Home > Close & Load to send the result to a worksheet. In Power BI Desktop, use Home > Close & Apply.
Common Mistakes
- Forgetting the column brackets. Writing
Number.ATan(YourColumn)without square brackets treats the name as an identifier, not a column reference, and fails. - Passing text. If the source column is typed as text (for example, numbers imported from a CSV with stray spaces),
Number.ATanreturns an error. Change the data type first, or clean the values with Trim and Replace. - Expecting degrees. The function always returns radians. Multiply by 180 and divide by
Number.PIfor degrees. - Using the wrong function name. It is
Number.ATan, notMath.ATanorNumber.Atan2. There is no two-argument arctangent in Power Query's standard library; for quadrant-aware angles you must compute them yourself fromNumber.ATanand the signs of x and y. - Ignoring case. M is case-sensitive.
Number.atanwill not resolve. - Assuming it works in a calculated column. Power Query functions run in the Power Query Editor, not in DAX. In DAX the equivalent is
ATAN.
Tips
- Test the formula on a small sample first. Add a custom column with a literal value like
Number.ATan(1)to confirm the function is available in your version. - Use the formula bar to edit the generated step rather than rebuilding the column. It is faster and keeps the query readable.
- Name the output column after the unit (for example, Angle_Deg) so nobody downstream assumes radians.
- Combine with
Number.Tanto round-trip values for validation:Number.Tan(Number.ATan(x))should return x for any real number. - If you need the angle in a chart, keep the radians column for calculation and add a separate degrees column for display.
- Document the formula in a comment step (right-click the step > Properties) so the next editor knows why the column exists.
Troubleshooting
The function is not recognized. Check spelling and capitalization: Number.ATan. Confirm you are in the Power Query Editor, not a worksheet cell. In Excel, the worksheet function is ATAN, not Number.ATan.
Every row returns an error. The input column is almost certainly text. Select the column, set Data Type to Decimal Number, and check for non-numeric characters. Use Transform > Replace Values to strip commas or currency symbols before converting.
Some rows are null. Null input produces null output in M by default in many contexts, but explicit guards make behavior predictable. Add the if ... then null else ... pattern shown above.
The result looks wrong. Verify the input is in the units you expect. Number.ATan takes a ratio, not an angle. If you passed degrees expecting degrees back, you have mixed up the direction of the function.
The query is slow. Row-by-row custom columns are fine for moderate data, but for very large tables consider whether the calculation can be pushed to the source database. Power Query will not fold Number.ATan to most sources, so it runs locally.
If that did not work, duplicate the query, remove all steps after the source, and rebuild the custom column one step at a time. This isolates whether the error comes from the function or from an earlier transformation.
Frequently Asked Questions
What does Number.ATan return?
The arctangent of the input number, in radians, in the range -π/2 to π/2. For example, Number.ATan(0) returns 0 and Number.ATan(1) returns approximately 0.7854.
How do I get degrees instead of radians?
Multiply the result by 180 and divide by Number.PI: Number.ATan([Column]) * 180 / Number.PI.
Is there an ATan2 function in Power Query?
No two-argument arctangent is exposed as a standard M function. You can build quadrant-aware angles manually using Number.ATan plus the signs of the x and y values, but it takes extra conditional logic.
Why does my column show errors after adding the function?
The most common cause is a text data type or non-numeric characters in the column. Set the data type to Decimal Number and clean the values first.
Does Number.ATan work in Power BI and Excel alike?
Yes. It is part of the M language used by Power Query in Excel, Power BI Desktop, Power Query Online and dataflows. The editor interface differs slightly, but the function call is identical.
Can I use Number.ATan in a DAX measure?
No. DAX has its own ATAN function. Number.ATan is only valid inside the Power Query Editor.