Number.Acos

D

T

The M Code Behind the Power Query M function Number.Acos

What is the Number.Acos Function?

The Number.Acos function is a Power Query M function that returns the arccosine of a given number. The arccosine of a number is the angle whose cosine is the given number. The Number.Acos function takes a single argument, which is the number whose arccosine is to be calculated. The function returns a decimal number, which represents the arccosine of the input number in radians.

The M Code Behind the Number.Acos Function

The M code behind the Number.Acos function is relatively simple. The following code snippet shows the M code for the Number.Acos function:


let

Number.Acos = (number as number) as number =>

if number >= -1 and number <= 1 then

Number.Acos = Math.Acos(number)

else

error “Invalid input”

in

Number.Acos


The code starts with the let keyword, which is used to define a variable. In this case, the variable is Number.Acos, which is the name of the function. The function takes a single argument, which is a number. The function returns a number, which is the arccosine of the input number.

The first line of the function checks whether the input number is between -1 and 1. If the input number is outside this range, the function returns an error message. Otherwise, the function calculates the arccosine of the input number using the built-in Math.Acos function.

How to Use the Number.Acos Function

Using the Number.Acos function in Power Query is very straightforward. To use the function, you need to follow these steps:

1. Open Power Query and create a new query.

2. In the Power Query Editor, select the Home tab and click on the New Source button.

3. Select the type of data source that you want to use and follow the prompts to connect to the data source.

4. Once you have connected to the data source, select the column that contains the numbers that you want to calculate the arccosine for.

5. Right-click on the selected column and select Transform -> Standard -> Number.Acos from the context menu.

6. Power Query will apply the Number.Acos function to the selected column and create a new column with the arccosine values.

In conclusion, the Number.Acos function is a powerful tool that can be used to calculate the arccosine of a given number in Power Query. The M code behind the function is relatively simple and easy to understand. By using the Number.Acos function, data analysts and business intelligence professionals can transform, clean and merge data from a variety of sources with ease.

Power Query and M Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)