Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
Menu

Get a decimal result when dividing numbers in Power Automate

Posted on April 6, 2022April 10, 2022 by Tom

“I’m dividing two numbers to convert ticks to days but Power Automate gives me only full days as a result, ignoring the decimal numbers!”


If you divide numbers in Power Automate, e.g. to convert ticks to days to get a time difference, you’ll use the div(…) expression. But there’s a small inconvenience using it. By default, if you divide two whole numbers, it’ll return a whole number. It won’t return a decimal result, just the whole number part. Instead of 0.5 you’ll get a 0, instead of 2.3 you’ll get 2, etc. That’s not very helpful, especially if you’re trying to calculate some percentages.

How do you then tell it to return also the decimal part of the result?

Use decimal number as an input

The reason is that the expression keeps the input data type. You entered two whole numbers (integers), it’ll return another whole number (integer).

Since the expression sticks to the original input type, you must change the input. Instead of using two whole numbers convert one of them into a decimal number (float). Applying the float(…) expression will convert the input number, and together with that also the division result. It doesn’t matter which input it’ll be, you can pick any of them.

float(<number>)

Note: <…> is a placeholder, replace it including the < and >.

Following with the example from above, the difference between now and 12 hours ago is 0.5 days, not a 0.

Power Automate dividing numbers decimal

Summary

When dividing numbers in Power Automate, you should always consider converting one of them into a decimal number (float). The result will be another decimal number and you won’t miss any piece of information (especially if you’re trying to calculate percentages).


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Now available:

The Ultimate Power Automate expressions cheat sheet
Equip yourself with the tool to translate your thoughts into Power Automate expressions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Format results of date calculation in SharePoint columnJune 29, 2022
  • Why is your Power Automate flow creating duplicatesJune 26, 2022
  • How to create a unique identifier in your Power Automate flowJune 22, 2022
  • How to assign custom SharePoint permission level with Power AutomateJune 19, 2022
  • Remove permissions from a specific SharePoint user with Power AutomateJune 15, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme