12
Views
2
Comments
Solved
Rounding Decimal Values to the Nearest Half or Whole Number
Question
Application Type
Reactive

Hello Community,

I'm working with a variable that contains decimal numbers, such as 47.77856 or 203.232354. This variable is GetFreelancersWithWorktime.List.Current.Costs and I'm trying to round these numbers so that the last digit of the decimal part is either a 0 or a 5.

For instance, I'd like to round 47.77856 to 47.80 and 203.232354 to 203.25.

I've attempted the following methods:

• Round(GetFreelancersWithWorktime.List.Current.Costs, fractionalDigits:2)
• FormatCurrency(GetFreelancersWithWorktime.List.Current.Costs, "CHF ", 2, ",", "'")

However, these do not produce the desired effect; they round to the nearest whole decimal, resulting in 47.78 and 203.23, respectively.

I'm looking for a technique that would allow me to round numbers so that the final digit after the decimal point is always a 0 or a 5. Any advice on how to achieve this rounding precision would be greatly appreciated.

Thank you for your time and assistance!

Solution

Hi,

There is no such built-in action, but you can build your own reusable function for this requirement.

It can contain something like:

ValueRounded = (Trunc(Value * 10) + If(Value * 10 = Trunc(Value * 10), 0, If(Value * 10 - Trunc(Value * 10) <= 0.5, 0.5, 1))) / 10

or

ValueRounded = Round(Value * 2, fractionalDigits:1) / 2

Note that rounding 203.23 to 203.25 is just plain wrong. It should be 203.20.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.