App Formula Average Not Working

bugs-issues-errors
expressions
(Daniel Billings) #1

I have a Virtual formula that calculates the average between two other fields. Whenever I edit the entries the formula calculates correctly;However, once the app syncs the value changes to 0.00%. Any thoughts on this? I have other virtual columns set up the same way that work as expected.

thanks for any help

(Steve Coile) #2

What are the column types of the columns you’re averaging, and the column type of the virtual column receiving the average?

(Daniel Billings) #3

The two columns I am averaging are both Number Type and the Virtual Column that is receiving the average is Percent Type.

(Daniel Billings) #4

I have the [Direct Run #] / [Production Rate #] = [Direct Run %]

(Steve Coile) #5

Try wrapping the Number types in DECIMAL() when used with AVERAGE(). E.g. DECIMAL([Direct Run #])

Many computer programs, including AppSheet, handle integer (Number) and real-number (Decimal) math differently. When an expression is entirely integers, the fractional component resulting from any calculations is simply dropped. To avoid losing that precision, you need to convert the integers to real numbers, either by wrapping the number with the DECIMAL() function, or by multiplying the integer by a real number (e.g., [Direct Run #] * 1.0).

(Daniel Billings) #6

The Decimal solution worked. Thanks for your help.

1 Like