Skip to main content
Solved

How can I round numbers in steps of 500 with FME?

  • July 27, 2021
  • 2 replies
  • 252 views

Dear FME community,

 

I have attributes which contain numbers with several integers like 5800386.006999999 as values. I would like to round these values in steps of 500. So the number above becomes 5800500. If the value is closer to e.g. 5801000 then it should be rounded to that number. If it is closer to 5800000 then it should be rounded to that. The values can have a lot of decimal places or none. This means the solution should be able to handle any given number.

 

I am very thankful for any help.

 

Thank you so much in advance!

Best answer by gazza

Divide the number by 500. Round it to the nearest integer. Multiply by 500.

In the AttributeManager it will look like

@Evaluate(@round(@Value(number)/500,0)*500)

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

gazza
Contributor
Forum|alt.badge.img+6
  • Contributor
  • Best Answer
  • July 27, 2021

Divide the number by 500. Round it to the nearest integer. Multiply by 500.

In the AttributeManager it will look like

@Evaluate(@round(@Value(number)/500,0)*500)


  • July 27, 2021

Thank you so much for your help. It works perfectly!