# Number.Tan

## #

In this article, we will take a deep dive into the M code behind the Power Query M function Number.Tan. We will explore how this function works and how it can be used to perform complex data transformations.

## Understanding the Number.Tan Function

The Number.Tan function is a mathematical function that returns the tangent of a given angle. It takes one argument, which is the angle in radians. The function returns a decimal number that represents the tangent of the angle.

The syntax of the Number.Tan function is as follows:

Number.Tan(number)

``` Where `number` is the angle in radians. For example, if we want to find the tangent of an angle of 45 degrees, we need to convert it to radians first. The formula to convert degrees to radians is: ```

``` Using this formula, we can convert 45 degrees to radians as follows: ```

``` Now, we can use the Number.Tan function to find the tangent of this angle as follows: ```

Number.Tan(0.785398)

``` This will return a value of 1, which is the tangent of 45 degrees. The M Code Behind the Number.Tan Function The Power Query M function Number.Tan is based on the .NET Framework Math.Tan method. The M code behind the function is as follows: ```

let

Tan = (x) =>

if x is number then

if x = Number.NaN then Number.NaN

else if x = Number.PositiveInfinity or x = Number.NegativeInfinity then Number.NaN

else Math.Tan(x)

else error Error.Record(“Invalid Input”, “Input must be a number.”)

in

Tan

``` The function takes one argument, `x`, which is the number (in radians) whose tangent we want to find. The function first checks if `x` is a number and if it is not, it returns an error. If `x` is a number, the function checks if it is NaN (Not a Number), PositiveInfinity, or NegativeInfinity. If `x` is any of these values, the function returns NaN (Not a Number). Otherwise, the function uses the Math.Tan method to find the tangent of `x`. The Number.Tan function is a powerful tool for performing mathematical operations on data in Power Query. It allows us to find the tangent of a given angle in radians. Understanding the M code behind this function can help us better understand how it works and how it can be used to perform complex data transformations. If you want to learn more about Power Query and its functions, there are many resources available online that can help you get started. 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) ```
``` ```
``` ```
``` ```
``` ```
``` ```