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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Error using the Sum fu...
Power Apps
Unanswered

Error using the Sum function

(0) ShareShare
ReportReport
Posted on by 23
Collect(colValores,{val: 84.7});
Collect(colValores,{val: 7.65});
Collect(colValores,{val: 7.65});
 
UpdateContext({locSum: Sum(colValores,val)})
 
//locsum = 100
//locsum > 100 returns true
//because locsum is in fact 100.0000000001
 
if i reverse the order of the collect to
 
Collect(colValores,{val: 7.65});
Collect(colValores,{val: 7.65});
Collect(colValores,{val: 84.7});
 
//locsum = 100
//locsum > 100 returns false
 
 
Categories:
I have the same question (0)
  • RobHardy Profile Picture
    154 on at
    Unfortunately, floating point errors are quite common across many programming languages / platforms.

    Since your values are all 2 decimal places or less, you could round the result to 2 places, which should fix the issue:
     
     
    UpdateContext({locSum: Round(Sum(colValores,val),2)})
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    In some of these situations such as currency it may be better to work with integer values then convert them back. 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 393

#2
WarrenBelz Profile Picture

WarrenBelz 345 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 271 Super User 2025 Season 2

Last 30 days Overall leaderboard