Skip to main content
Solved

Hello, I have a list of numbers that I want to round to the closest even number after the point. It should round it to one decimal. What formula to use ?


katt
Supporter
Forum|alt.badge.img+12
  • Supporter

Here are some examples:

original data

497.2594497509648

497.3865

495.31

495.29

expected result:

497.2

497.4

495.4

495.2

And I have another case where I want to round my list of numbers to the closest of four options: integer, ending with .25 or ending with .5 or ending with .75.

my examples:

original data

497.2594497509648

497.8865

495.77

495.45

expected result:

497.25

498

495.75

495.5

thank you.

Best answer by DanAtSafe

Scenario 1, multiply by 5, round, then divide by 5 

@round(@Value(attrib1) * 5) / 5

 

View original
Did this help you find an answer to your question?

3 replies

hkingsbury
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • March 14, 2022

In your examples, you inconsistently round - eg 497.3895 and 495.31 both round up to xxx.4, whereas 495.29 rounds down to 495.2.

 

Scenario 1, use the AttributeRounder

scenario 2, use the following statement - @Evaluate(@round(@Value(_list)*4,0)/4)

 

 


DanAtSafe
Safer
Forum|alt.badge.img+18
  • Safer
  • Best Answer
  • March 14, 2022

Scenario 1, multiply by 5, round, then divide by 5 

@round(@Value(attrib1) * 5) / 5

 


hkingsbury
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • March 14, 2022
hkingsbury wrote:

In your examples, you inconsistently round - eg 497.3895 and 495.31 both round up to xxx.4, whereas 495.29 rounds down to 495.2.

 

Scenario 1, use the AttributeRounder

scenario 2, use the following statement - @Evaluate(@round(@Value(_list)*4,0)/4)

 

 

@katt​, misread the first part re even numbers. @danatsafe​  gives the correct answer :)


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings