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 Apps / Division not working?
Power Apps
Answered

Division not working?

(0) ShareShare
ReportReport
Posted on by 121

So I have two tables (Sharepoint lists)

One uses a lookup from the other.

 

I have two galleries displaying them, basic set up is top gallery consists of Customers, lower gallery Customer orders.

What I'm trying to achieve is I want to do with AddColumns a calculation that gives me the percentage of items in the order delivered.

 

The idea with this to count the rows in Customer Order Based on the Customer ID, where status is "Levererad"(delivered), exclude Articles that contains "Behöver" divide those by the number of articles in the customer order that doesn't contain "Behöver" or that doesn't contain "Makulerad" in the field Status.

 

This is the item property in the gallery

 

AddColumns(
 Huvudorder,
 "PR",
 RoundDown(
 CountRows(
 Filter(
 Artikel_Order,
 Artikel_Order[@Status] = "Levererad" && Anställd.Id = Huvudorder[@ID] && (IsMatch(
 Artikel.Value,
 "Behöver",
 Contains
 ) = false)
 )
 ) / CountRows(
 Filter(
 Artikel_Order,
 Anställd.Id = Huvudorder[@ID] && (IsMatch(
 Artikel.Value,
 "Behöver",
 Contains
 ) = false) && (IsMatch(
 Status,
 "Makulerad",
 Contains
 ) = false)
 )
 ) * 100,
 0
 )
)

If I change the / to either a +,- or * it works. But the / just leaves me with a blank gallery.

 

If I skip the AddColumns Part and inject the same formula into a TextLabel in the gallery it works.

 

Any idea on why this just won't work?

Categories:
  • Verified answer
    mdevaney Profile Picture
    29,993 Moderator on at

    @drawser 

    One possibility for error when dividing a number might be a "divide by zero" error.  What happens if you encapusulate the calculation within an IFERROR function and return 0 for any errors?

     

    AddColumns(
     Huvudorder,
     "PR",
     IfError(
     RoundDown(
     CountRows(
     Filter(
     Artikel_Order,
     Artikel_Order[@Status] = "Levererad" && Anställd.Id = Huvudorder[@ID] && (IsMatch(
     Artikel.Value,
     "Behöver",
     Contains
     ) = false)
     )
     ) / CountRows(
     Filter(
     Artikel_Order,
     Anställd.Id = Huvudorder[@ID] && (IsMatch(
     Artikel.Value,
     "Behöver",
     Contains
     ) = false) && (IsMatch(
     Status,
     "Makulerad",
     Contains
     ) = false)
     )
     ) * 100,
     0
     ),
     0
     )
    )

     

    ---

    Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

  • drawser Profile Picture
    121 on at

    Yup, thanks alot!

    That fixed the issue, I didn't even reflect over the ifError cause it worked in a textlabel.

     

    Added it in there and now it works as intended.

     

    Many thanks!

     

     

  • mdevaney Profile Picture
    29,993 Moderator on at

    @drawser 

    No problem.  It was instinctive to me after many years of preparing reports in Excel and getting the #DIV0 error. LOL.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard