I have an app that was working well. However, I now get an Invalid Operation: Division by zero error. I can't seem to find where the error is with the app checker. Does anyone have a suggestion on how to easily find this error?
I had a similar issue with a responsive app I built. In my case it turned out to be a timing problem. I was using a value on one of the pages that was calculated at startup based on the app size. The problem was some other calculations were using it prior to the app fully starting so the value was still zero. I fixed it by adding an if statement around the calculation that checked to see if the size I was using was zero or not before doing the calculation. That fixed the issue.
I found the equation causing the issue by using the monitor in the designer. It shows you what happens in the app as it loads and runs. That's where I found the error flagged. You can read about the monitor here:
Monitor overview - Power Apps | Microsoft Docs
Hi @ahhollan ,
I guess you only see this error when you play the App.
Let's consider few scenarios,
1. You have created some dynamic stuff on your screen which doesn't load at that instant but the formula executes in order to show you the control or run OnStart while you play the App.
Consider this example,
If you have a gallery of Tab buttons (say 5 items) and you create a dynamic 'Template Size' formula as such
Parent.Width/CountRows(Gallery.AllItems)
In this case, when your App runs, Gallery.AllItems may contain 0 records. Thus pushing the error that you got.
To avoid this, if you know that there are 5 items in gallery then insert that in your formula.
Parent.Width/5
2. Now let's say you have some collection that executes later or has 0 records and you need to show or create some dynamic content or size of control accordingly. Which will throw the error since collection has 0 records.
Consider this example,
If you want to show dynamic width of a control based on items in collection.
Add a condition to first null check the items, if its greater than 0 then perform dynamic task.
If(CountRows(colTodaysTask) > 0, <----Your Code---->, Notify("Ërror")(optional) )
So basically whenever we have dynamic operations in the App, consider having null checks or initial load up of the screen which depends on some values which populates before the layout than its items or any other possible stuff.
Re-check your formulas.
Hope this helps.
So I ran the monitor and the app found one delegation error and another formula error. I fixed the formula error, and the app runs clean in design mode. However, when I open the app normally (not in edit mode) I still get the error. The monitor isn't picking up anything.
User | Count |
---|---|
156 | |
91 | |
80 | |
74 | |
57 |
User | Count |
---|---|
197 | |
166 | |
99 | |
95 | |
79 |