Number.Atan2

What is the Number.Atan2 Function?

The Number.Atan2 function is a mathematical function that calculates the arctangent of the quotient of two numbers. It takes two arguments: x and y. The function returns the angle in radians between the positive x-axis and the point (x, y) on the Cartesian plane.

The Number.Atan2 function is commonly used in engineering and scientific applications to calculate the angle between two points. For example, it can be used to calculate the direction of a vector, or the angle between two lines.

The M Code Behind the Number.Atan2 Function

The M code behind the Number.Atan2 function is relatively simple. The function takes two arguments, x and y, and calculates the arctangent of the quotient of the two numbers using the Excel ATAN2 function.

Here is the M code for the Number.Atan2 function:

let

Number.Atan2 = (x as number, y as number) as number =>

Excel.WorkbookFunction.Atan2(x, y)

in

Number.Atan2

``` The code defines a function called Number.Atan2 that takes two arguments, x and y. The function uses the Excel.WorkbookFunction.Atan2 function to calculate the arctangent of the quotient of x and y, and returns the result as a number. Using the Number.Atan2 Function in Power Query To use the Number.Atan2 function in Power Query, you first need to load the function into Power Query. This can be done by creating a new query and pasting the M code for the function into the Advanced Editor. Once the function is loaded, you can use it in your queries like any other function. For example, here is a query that calculates the angle between two points: ```

let

Source = Table.FromRows({{1, 2}, {3, 4}}, {“x”, “y”}),

``` The query creates a table with two columns, x and y, and calculates the angle between each point using the Number.Atan2 function. The result is a new column called Angle that contains the angle in radians between each point and the positive x-axis. The Number.Atan2 function is a useful mathematical function that is commonly used in engineering and scientific applications. In Power Query, the function can be loaded using the M code provided above, and used like any other function. By understanding the M code behind the function, you can gain a deeper understanding of how Power Query works, and how to use it to manipulate and transform data. Power Query and M Training Courses by G Com Solutions (0800 998 9248) Power Query and M Intensive Training Course £1,050.00 – £26,550.00 Select optionsContinue Loading Done Power Query and M Introduction £395.00 – £9,750.00 Select optionsContinue Loading Done Power Query and M Intermediate £395.00 – £9,750.00 Select optionsContinue Loading Done Power Query and M Advanced £395.00 – £9,750.00 Select optionsContinue Loading Done Upcoming Courses Contact Us Subject Your Name (required) Company/Organisation Email (required) Telephone Training Course(s) Power BI Intensive TrainingPower BI introduction Power BI IntermediatePower BI AdvancedDAXPower Query MPower BI CertificationPower BI AdministrationPower PlatformPower AutomatePower AppsOTHER Your Message Upload Example Document(s) (Zip multiple files) ```
``` ```
``` ```
``` ```
``` ```
``` ```