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

Community site session details

Session Id : NyqQKMoL6Y8jadkzNCtEwt
Power Apps - Building Power Apps
Answered

Please help: Sum function results in Incorrect Calculation (off by 2)

Like (0) ShareShare
ReportReport
Posted on 14 Sep 2016 18:52:54 by 987

Let me start with the scenario:

I have a sharepoint list (WOServices) with work order details and cost values. The list has 5 columns, with only 1 complex column (performed by/people column). I also have a Power App that is connected to it, which is submitting work order items and cost values to that list. Everything is working perfectly as far as list submission goes.

 

The WOServices list currently has 28 rows in it, and every row has been created today. However, in practice, there will be an average of 30 rows for each day, with the list itself growing to around 3,600 records in a year. We have a default view which is scoped to this weeks records - so the default view will never exceed 150 records. Tools: The default view in SharePoint, AND all historical entries not shown in it, will be connected to a Power BI Dashboard. On the other hand, all data entries will be done using Power Apps (tablet form).

 

Problem

I would like to include a read only text label in the header area of the form which sums all the orders for that day only. As a result, each time the form is opened, there is a daily tally for the day at the top in the header.

 

I'm using this function in the text label in the header:

Text(Sum(Filter(WOServices, IsToday(Created) = true), Cost), "$ #,###")

 

Only, the total comes out to be $185.00 in PowerApps, but in SharePoint (Default View Totals the Cost column) it adds up to $187.00 for that day.

 

So I exported the list to Excel to use sum formula to determine which was right; and SharePoint is right and Power Apps is wrong! This was a bit scary, can anyone shed any light on why this might be happening?

 

Thank you.

 

Categories:
  • AndyPennell Profile Picture
    on 27 Sep 2016 at 22:57:33
    Re: Please help: Sum function results in Incorrect Calculation (off by 2)

    Text box wont update unless it needs to (eg it refers to data that has changed), so in this example then yes: it will not update by itself. (Use a Timer if you want to update it on a regular basis).

     

    I have not been able to find a bug in in the isToday function, but it was over-complicated so I replaced it with a much simpler implementation. It uses local time for the check, so you should verify that Sharepoint is giving you date/times in your timezone for the comparison to be valid.

  • audrieFCT Profile Picture
    987 on 14 Sep 2016 at 20:01:47
    Re: Please help: Sum function results in Incorrect Calculation (off by 2)

    One more thing rgruian.

     

    I put a text box on my screen to see what date and time it thinks it is, and sure enough, it was 1 hour earlier (which would make that 12:09 read as the previous date). (So it's not UTC, maybe it's server time)

     

     

    timecapture1207PM.PNG


    *******Update******

    Oddly enough when I closed and reopened the app, the time displayed correctly (now 13:06:34)....so maybe the text box doesn't update until you restart an instance of the app.

  • audrieFCT Profile Picture
    987 on 14 Sep 2016 at 19:28:57
    Re: Please help: Sum function results in Incorrect Calculation (off by 2)

    Yes, you are correct: when I remove the IsToday(Created) filter the cost total is now correct.

    P.S. To further validate, I deleted that row, and added another created just now - and again the total was correct even with the date filter. So obviously "12:09AM" was not read by PowerApps as today (whereas it was by the SharePoint view).

     

    Here is the data:

     Cost, Created
    0, 9/14/2016 2:31
    0, 9/14/2016 2:29
    0, 9/14/2016 2:30
    20, 9/14/2016 2:23
    0, 9/14/2016 2:31
    30, 9/14/2016 2:26
    11, 9/14/2016 2:19
    0, 9/14/2016 2:29
    2, 9/14/2016 2:35
    3, 9/14/2016 2:20
    0, 9/14/2016 2:21
    20, 9/14/2016 2:23
    20, 9/14/2016 2:26
    0, 9/14/2016 1:14
    13, 9/14/2016 2:11
    10, 9/14/2016 2:35
    0, 9/14/2016 2:30
    0, 9/14/2016 3:16
    0, 9/14/2016 3:18
    0, 9/14/2016 3:18
    27, 9/14/2016 2:22
    26, 9/14/2016 1:45
    2, 9/14/2016 0:09
    3, 9/14/2016 2:35
    0, 9/14/2016 3:17
    0, 9/14/2016 3:17
    0, 9/14/2016 3:18
    0, 9/14/2016 3:16

     

    Thank you for logging the bug!

    Repro: Have the SharePoint List View Total the Cost Column
    Create expression in Power Apps in text box:
    Text(Sum(Filter(WOServices, IsToday(Created) = true), Cost), "$ #,###")

  • rgruian Profile Picture
    on 14 Sep 2016 at 19:19:53
    Re: Please help: Sum function results in Incorrect Calculation (off by 2)

    Try this:


    Sum(WOServices, Cost)

     

    if that gives you the correct result, then yes -- it's an issue with the notion of "today". I will file a bug regardless. It would be helpful to have your exact data for repro (just those two columns would suffice).

     

    Thanks.

     

  • audrieFCT Profile Picture
    987 on 14 Sep 2016 at 19:17:46
    Re: Please help: Sum function results in Incorrect Calculation (off by 2)

    Ok, well - that's a nasty bug for anyone in manufacturing or retail that needs to track costs or other numbers by datee. But, I'll go with it for now! Thanks for offering to help!

  • rgruian Profile Picture
    on 14 Sep 2016 at 19:16:44
    Re: Please help: Sum function results in Incorrect Calculation (off by 2)

    It's hard to tell without actually debugging on the real data, but I guess that is a possibility.

  • Verified answer
    audrieFCT Profile Picture
    987 on 14 Sep 2016 at 19:15:04
    Re: Please help: Sum function results in Incorrect Calculation (off by 2)

    Pasted Cost Column (test values) in message below, with create times.

     

     

  • Verified answer
    audrieFCT Profile Picture
    987 on 14 Sep 2016 at 19:13:57
    Re: Please help: Sum function results in Incorrect Calculation (off by 2)

    So in scanning the list - I think I might have a "clue" (it's not worth much in resale value though-LOL). There is a line item of $2.00 that has a created time of 12:04 AM today which technically makes it the same day as all the rest. (Yes, I work all hours of the day and night - lol). However, I vaguely remember someone saying that Power Apps clocks are not literal but UTC or something like that (that they differ from SharePoint in some way). So perhaps that line item is not being understood as today.

     

    Do you think that could be it? If so, that might not be an issue since I'm the only nut working at midnight.

  • rgruian Profile Picture
    on 14 Sep 2016 at 19:12:13
    Re: Please help: Sum function results in Incorrect Calculation (off by 2)

    Can you please paste the Cost column here? (all 28 values)

    Thank you.

  • audrieFCT Profile Picture
    987 on 14 Sep 2016 at 19:08:54
    Re: Please help: Sum function results in Incorrect Calculation (off by 2)

    Yes, I have done a evaluation of the data and found no flaws (FYI: SharePoint column totals would be wrong too if the data formats were flawed.)

     

    There are currently 28 rows in the list - and I can't tell where the "2" of the total is missing.

     

    The Cost column is numeric and there are no null values.

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

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete