Calculations....

For HanDBase related topics that are not specific to one platform.

Calculations....

Postby cad » Mon Jul 27, 2009 12:47 am

Dave,

I have a question about calculations in HDB. I am looking at two databases that I have written and the numbers are completely wrong, particularly when editing. Nested equations are the worse. Anything in parentheses will invariably give me two different results. Sometimes when I change a variable, the final number does not change at all.

I remember this happening with Smartlist when I used my Palm and the solution at the time was to use a "Recalc" button. Is HDB in need of a recalc button to ensure accuracy? I did notice that this occurs on the Windows desktop as well as on the iPhone, thus this does not appear to be just an iPhone issue.

c.
cad
 
Posts: 8
Joined: Sun Jul 19, 2009 1:21 pm

Re: Calculations....

Postby dhaupert » Mon Jul 27, 2009 11:01 am

cad wrote:Dave,

I have a question about calculations in HDB. I am looking at two databases that I have written and the numbers are completely wrong, particularly when editing. Nested equations are the worse. Anything in parentheses will invariably give me two different results. Sometimes when I change a variable, the final number does not change at all.

I remember this happening with Smartlist when I used my Palm and the solution at the time was to use a "Recalc" button. Is HDB in need of a recalc button to ensure accuracy? I did notice that this occurs on the Windows desktop as well as on the iPhone, thus this does not appear to be just an iPhone issue.

c.


Typically this happens when the order of calculations is not done in the order needed for the calculations to be correct. HanDBase evaluates calculations based on the display order of fields- that is the field order for that view (if a view is selected) or if no view yet set, the Edit Field order section of the DB properties.

For example, if your database had something like this:

Field 1: Calc based on Field 2 and Field 3 added together
Field 2: Calc based on Field 5 date field subtracted from today.
..
and the order of the view is:
Field 1,Field2, Field3,..

Field 1 will be evaluated first. At this time, the Field 2 value is 0 as it hasn't been calculated yet. An erroneous answer occurs for this reason.
If you change the field order to this:
Field 2,Field 1,Field 3
The answer would come out correctly as Field 2 would be evaluated before Field 1 accesses the value.

The reason why the calculation often then displays properly when you open or close the record for editing repeatedly is that the later fields fill in with a good value and the earlier fields when reevaluated on subsequent opens will have the correct value.

We made the auto recalculation such that the need to manually recalc should never be there. For the last 12 years it's worked out pretty well, and often exposes these types of issues which would still be an issue even with an auto recalc. Please let me know if you need me to take a look at your database and see where the problem may lie!
dhaupert
 
Posts: 4111
Joined: Tue May 26, 2009 11:51 am


Return to HanDBase General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron