Number.Exp

D

T

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

One of the functions you can use in M is Number.Exp. In this article, we will explore the M code behind this function and learn how to use it.

What is Number.Exp?

The Number.Exp function in Power Query is used to calculate the exponential value of a given number. The exponential value of a number is calculated by raising the mathematical constant e (approx. 2.71828) to the power of the number.

For example, if we want to find the exponential value of 2 using the Number.Exp function, we would use the following formula:


Number.Exp(2)


This would return the value of 7.38906.

Understanding the M Code Behind Number.Exp

Now that we know what the Number.Exp function does let's take a closer look at the M code behind it.

The M code for the Number.Exp function is as follows:


(number as number) as number =>

let

e = 2.718281828459045,

result = Number.Power(e, number)

in

result


Here is a breakdown of what this code does:

- The first line defines the input parameters for the function. In this case, we only have one input parameter, which is the number we want to use to calculate the exponential value.

- The next line defines the output data type for the function. In this case, the output data type is also a number.

- The "let" keyword is used to define variables that will be used within the function. In this case, we define a variable "e" equal to the mathematical constant e. We also define a variable "result" equal to the result of raising e to the power of the input parameter "number".

- Finally, we return the value of the "result" variable.

Using Number.Exp in Power Query

Now that we understand the M code behind Number.Exp, let's see how we can use it in Power Query.

To use Number.Exp in Power Query, we first need to create a new query. We can do this by clicking on the "New Source" button on the Home tab of the Power Query editor.

Once we have created a new query, we can then use the Number.Exp function to calculate the exponential value of a number. To do this, we need to add a new column to our query and enter the following formula:


= Number.Exp([Number])


This formula will calculate the exponential value of the "Number" column in our query.

In conclusion, the Number.Exp function in Power Query is a useful tool for calculating the exponential value of a number. The M code behind this function is simple and easy to understand, and we can use it to create custom queries that manipulate data in various ways.

By understanding how to use Number.Exp in Power Query, we can improve our data analysis skills and create more efficient and effective data workflows.

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)