VC value changed after saving

Hi you all!

I am having some trouble with a virtual column on a shift tracker app.

I have:
[Start] and [Finish] columns as DateTime
[Deductible Break] as Duration

[Units] as Enum (“per day” or “per hour”)

VC [Payable] with the formula:
[Finish]-[Start]-[Deductable Break]

VC [Pay] as Decimal with the formula:
IF(HOUR([Payable])+(MINUTE([Payable])/60)<8,8,HOUR([Payable])+(MINUTE([Payable])/60))
(minimum 8hrs paid)

[Rate] as Price

VC [Subtotal] as Price with the formula:
IF([Units]=per day,[Rate],[Rate]*[Pay])

!!!ISSUE!!!

If the [Units] is set to “per day” and the [Rate] will be 102.50 then the [Subtotal] will stay be and stay as 102.50.

If the [Units] is set to “per hour” and the result will be 102.50, this will be shown in the form and after saving but after sync, it will round it up to 100.

Can’t find where the rounding up is happening.

Any clues?

Thanks!

In the form:

Detail:

After sync:

It most likely has to do with decimal vs number… Maybe take that whole expression, and wrap it with a *1.0 see if that does it, then hone in on exactly where to make that tweak.

3 Likes

Thank you!
Just tried it but it still does the same thing

AlexM:

IF(HOUR([Payable])+(MINUTE([Payable])/60)<8,8,HOUR([Payable])+(MINUTE([Payable])/60))

Could you please try with
IF(HOUR([Payable])+(MINUTE([Payable])/60)<8.00,8.00,(HOUR([Payable])) * 1.00+(MINUTE([Payable])/60.00))

Edit: Minor modification to the expression

4 Likes

Suvrutt_Gurjar:

IF(HOUR([Payable])+(MINUTE([Payable])/60)<8.00,8.00,(HOUR([Payable])) * 1.00+(MINUTE([Payable])/60.00))

ok, it works! thank you!

WHY?
What’s *1.00 doing and what’s /60.00 doing?

I believe @Steve may give correct explanation. I will try.

However as per my understanding , the earlier expression was giving a rounded number value , because even though the column type is DECIMAL , all expression calculations were based on NUMBER types. I believewith reference to the help document below, the earlier expression was equivalent of first example in the help document , that is DECIMAL(10 / 3) = (3.0)

I may be incorrect in my above explanation.

I suggested revised expression by previous experience of working with decimal calculations and of course some testing in similar test scenario.

5 Likes

@Suvrutt_Gurjar Thanks for getting in there!

1 Like

Hi @Grant_Stead,

Thank you. I just further expanded on your hint of gettting the expression into decimal format from number format.

Suvrutt_Gurjar:

expanded on your hint

In general I try to allow a little room for self exploration…

2 Likes

Click through the below for more on this issue:

[Fix for expression giving 0% or missing decimal part](https://community.appsheet.com/t/fix-for-expression-giving-0-or-missing-decimal-part/15061) Tips & Tricks ?

Trying to divide two numbers to get a percentage but always getting 0? Trying to divide two numbers but losing the numbers after the decimal point? TRY THIS Convert one or both of the values in your division expression to a Decimal value, either by: (1) wrapping the value in the expression with the DECIMAL() function; (2) multiplying the value in the expression by 1.0; or (3) changing the column’s type to Decimal if suitable to the app. FOR EXAMPLE If computing a percentage from two Number co…

4 Likes