web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Strange Behavior on co...
Power Automate
Answered

Strange Behavior on converting Text to numbers

(0) ShareShare
ReportReport
Posted on by 152

Hi,

I have a flow that has been running for over a year without problems.  It will get a many rows of data from a data source.

Then, I will loop through each line to get a sum total. 

 

The JSON data field could look something like this:

 
 "Amount"-5.61,
or 
"Amount": 120, 
 
As l loop through the data using the below, 
dchan1_0-1707918644617.png


items('Apply_to_each_-_GL_Entries_1')?['Amount']

 

Lately, I found that the sum total may be off by 0.01!

 

As I traced through the steps, I found that the 0.01 error often happen with "Amount" that has 2 decimals, but not always.

When the error occurs, using the example of 5.61 above, I may get something like 5.6099999999.

 

Why is this happening?  Any idea?  

 

Seeing this behavior,  I put in a fix for it.  

 

dchan1

Categories:
I have the same question (0)
  • Verified answer
    SamLed Profile Picture
    2,340 Moderator on at

    Hi @dchan1,

     

    There is obviously a weird behavior probably due to decimal precision used behind the scene, but no reason a 2 decimal float becomes a 10 decimal one with a 0.0000000001 difference. I have to admit I can't explain why.

     

    However, I have a workaround that may interest you, as there is no round() function available, to correct the result to what is expected, have a look to following flow design to illustrate:

     

    SamLed_1-1707925023836.png

    SamLed_4-1707925303045.png

     

    Results:

    SamLed_3-1707925157516.png

     

    Explanations:

    • I used a JSON array containing a bunch of objects with amount property as source. To be in same context than your source.
    • I increment the variable with each value
    • Use "Format Number" to round variable value to 2 decimal float
    • Display variable value and Format Number result.

    Remark: "Format Number" returns a string, I convert it back to float in display compose, useless here, but it was to introduce that point.

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

  • dc7669 Profile Picture
    152 on at

    Hi @SamLed , 

     

    Thanks for your time in looking into this. I see that you can reproduce the issue! 

    So, I guess we just need to be aware this behavior when we use PowerAutomate to do calculations.

     

    Thanks for the suggestion of using "Format Number" to get around this issue.

     

    I tested it to be working.  

     

    Thanks. 

     

    dchan1

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 271 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 171 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 148 Super User 2026 Season 2

Last 30 days Overall leaderboard