Power Automate
How to Round (Up; Down) Decimal in Power Automate

How to Round (Up; Down) Decimal in Power Automate

Decimal numeric Round-off is a renowned Math operation, that will always be a necessity while working with numbers irrespective of its complexity.

When it comes to Canvas app, we have multiple built-in methods available for Rounding a decimal namely Round, RoundDown and RoundUp.

Round(NumberDecimalPlaces)
RoundDown(NumberDecimalPlaces)
RoundUp(NumberDecimalPlaces)

We also have scenarios to Round-off the decimal values in Power Automate. But, to our surprise Microsoft has no specific function provided in the expressions, instead we will have to use an action named “Format Number” under “Number Functions” category.

Format number only does a Round function in a traditional way by rounding up if the decimal digit is 5 or higher. Otherwise, this function rounds down. For Instance: 
1.1 to 1, 
1.5 to 2. 

This Format Number action enables us to perform a variety of number formatting options easily by leveraging number formatting patterns like other Power Platform services. Formatting a number includes a custom format, which is used to Round up a decimal value to an integer just by specifying “#” in the format field. This action also can

  • Format the appearance of the number based on typical patterns such as Currency($) formats.
  • Custom formatting patterns likely to Excel, Power BI and Power Apps expressions.
  • Try currency formats as per the business requirements, specific to locales.
  • Also formats C2 (currency with two decimal places), and N2 (negative number with two decimal places).
For a customized Round up option like 
1.1 -> 2;
1.5 -> 2, a manual arithmetic expression should be built within the variable action.
<Expression> 
if(and(less(int(last(split(string(variables('varIntDecimal')),'.'))),int(9)), 
greaterOrEquals(int(last(split(string(variables('varIntDecimal')),'.'))),int(1))),
add(int(first(split(string(variables('varIntDecimal')),'.'))),1), int(first(split(string(variables('varIntDecimal')),'.'))))

You can also customize a decimal numeric with formatting options based on locale. Also, build your own expressions for formatting a numeric based on a custom requirement apart from the traditional round-off. In case of queries, please post your ’em in the comments section.

Stay Tuned! Happy Building… šŸ™‚

0

Leave a Reply

Newsletter Signup

Subscribe to our weekly newsletter below and never miss out the latest updates

%d bloggers like this: