Number.RoundDown

D

T

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

What is the Number.RoundDown Function?

The Number.RoundDown function is a Power Query M function used to round a number down to the nearest integer. It takes two arguments: the number you want to round and the number of decimal places you want to round down to. Here is an example of the Number.RoundDown function:


Number.RoundDown(3.14159, 2)


In this example, the function rounds the number 3.14159 down to 2 decimal places, resulting in the number 3.14.

The M Code Behind the Number.RoundDown Function

The M code behind the Number.RoundDown function is fairly simple. Here is the M code for the Number.RoundDown function:


let

roundDown = (number as nullable number, decimals as number) =>

if number <> null then Number.RoundDown(number, decimals) else null

in

roundDown


The M code defines a function called 'roundDown' that takes two arguments: 'number' and 'decimals'. The function then checks if the 'number' argument is not null. If the 'number' argument is not null, the function calls the Number.RoundDown function with the 'number' and 'decimals' arguments. If the 'number' argument is null, the function returns null.

How to Use the Number.RoundDown Function

To use the Number.RoundDown function in Power Query, follow these steps:

1. Open Power Query and select the data you want to transform.

2. Click on the 'Add Column' tab and select 'Custom Column'.

3. In the 'Custom Column' dialog box, give the new column a name and enter the following formula:


Number.RoundDown([Column Name], [Number of Decimal Places])


Replace 'Column Name' with the name of the column you want to round and 'Number of Decimal Places' with the number of decimal places you want to round down to.

4. Click 'OK' to add the new column to your data set.

In this article, we explored the M code behind the Power Query M function Number.RoundDown. We learned that the function is used to round a number down to the nearest integer and takes two arguments: the number you want to round and the number of decimal places you want to round down to. We also saw the M code that defines the function and how to use the function in Power Query. By using the Number.RoundDown function, you can easily round your data down to the desired number of decimal places and prepare it for analysis.

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)