A virtual column gives 0.0000 from formula 1/2

The virtual column is decimal type having 4 decimal digits.

3X_b_7_b74d30bd4a50acd1347f55a0f6894eb8d1ca2d67.jpeg

given result is

3X_c_5_c548c9a0d7120d86d2b4e9ccf41f1bffe335f906.jpeg

The expected result is 0.5000.

Why?

Solved Solved
1 16 375
1 ACCEPTED SOLUTION

Then I would expect:

  • [column a]-[column b]/2 to give 0.5

  • [column a]-([column b]/2) to give 0.5

  • ([column a]-[column b])/2 to give 0

But if they are instead of type Number:

  • [column a]-[column b]/2 would give 1

  • [column a]-([column b]/2) would give 1

  • ([column a]-[column b])/2 would give 0

View solution in original post

16 REPLIES 16

Please try

1/2.0000 as app formula.

Thanks but regret to say that it does not answer my question.

Division with integers ( 1/ 2) , will have integer result. (0)

Dividing by 2.0000 brings in decimal division. Number of decimal points in denominator will give decimal points in answer. Division by 2.0 will result in 0.5

Thank you very much.

Read the document I refered to .

Steve
Platinum 4
Platinum 4

Thanks Steve. If an expression contains [columns], the result seems ok. In my case there was pure numbers with operators, adjusting the decimal points of virtual column does not help showing the expected value.

Anyway that was just my experiment, there is no use in real apps.

What does this have to do with anything?

All this started from my curious of how AppSheet prioritizes the math operators in calculations (I have not seen any documentations mention about it).

To check if 1-1/2 returns 0.5 (like scientific calculators) or 0 ? I created a virtual column to test it. The result was 0. But I could not conclude that the result 0 was from calculation or from displaying behavior.

If AppSheet does scientific way, I will not use extra ( ) in my expressions.

AppSheet applies common math order of operations, but order of operations is not the problem with your expression.

To make things clear, what are the results from this following expressions in AppSheet?

[column a]-[column b]/2 =?

[column a]-([column b]/2) =?

([column a]-[column b])/2 =?

If the values of [column a] and [column b] are 1.

What are the column types of column a and column b?

Absolutely decimal type.

Then I would expect:

  • [column a]-[column b]/2 to give 0.5

  • [column a]-([column b]/2) to give 0.5

  • ([column a]-[column b])/2 to give 0

But if they are instead of type Number:

  • [column a]-[column b]/2 would give 1

  • [column a]-([column b]/2) would give 1

  • ([column a]-[column b])/2 would give 0

Thank you

Top Labels in this Space