# Number.Cos

## What is M code?

M code is the language used by Power Query to perform data transformations. It is a functional language that allows you to create complex queries that manipulate data in various ways. M code is generated automatically by the Power Query interface, but you can also edit it manually if you need to perform more advanced transformations.

## How does the Number.Cos function work?

The Number.Cos function is a built-in function in Power Query that returns the cosine of a given angle in radians. The syntax of the function is as follows:

Number.Cos(number)

``` The function takes a single argument, which is the angle in radians. The function returns the cosine of the angle. For example, if you want to calculate the cosine of an angle of 45 degrees, you would first convert the angle to radians using the Radians function, like this: ```

``` This would return a value of approximately 0.707. The M code behind the Number.Cos function When you use the Number.Cos function in Power Query, the M code generated by the interface looks like this: ```

= (number) => Number.Cos(number)

``` This code defines a lambda function that takes a single argument, which is the angle in radians. The function calls the Number.Cos function and passes the angle as its argument. The result is then returned by the lambda function. The lambda function is a way to define a function in-line, without having to give it a name. It is a powerful tool that allows you to create complex functions on-the-fly, as needed. Using the Number.Cos function in Power Query To use the Number.Cos function in Power Query, you can simply enter the function into a cell in the query editor. You can also use the function in other queries or custom functions. For example, if you have a table of angles in degrees, you can use the following formula to calculate the cosine of each angle: ```

``` This formula adds a new column to the table called "Cosine". The formula uses the Number.Cos function to calculate the cosine of each angle in radians, using the Radians function to convert the angles from degrees to radians. The Number.Cos function is a powerful tool in Power Query that allows you to calculate the cosine of a given angle in radians. The M code behind the function is simple and easy to understand, making it a useful tool for anyone working with data in Power Query. By understanding how the function works, you can create more complex queries and custom functions that manipulate data in even more powerful ways. 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) ```
``` ```
``` ```
``` ```
``` ```
``` ```