Rounding to nearest half

Hi,

I have a number of temperatures which I would like to round off to the nearest half degree, similar to what the mround function in Excel does. Is this possible with the Round Double node, or otherwise?

Thanks/Evert

|20.1|20|
|20.35|20.5|
|20.42|20.5|
|20.42|20.5|
|20.5|20.5|
|20.64|20.5|
|20.72|20.5|
|20.88|21|
|20.95|21|
|21.03|21|
|21.18|21|
|21.19|21|
|21.33|21.5|
|21.41|21.5|
|21.64|21.5|
|21.72|21.5|
|21.72|21.5|
|21.79|22|
|22.01|22|

Hi Evert.

You can do such calculation with Column Expressions node.

Example is attached.

mround.knwf (6.0 KB)

4 Likes

Hi Alex,

Thanks for your swift reply, this was what I was looking for. I actually did not have the Column Expressions node installed, wasn’t aware of its existence.

Many thanks/Evert

1 Like

You are welcome.

I assume you can get the same result with combination of Math and Rule Engine nodes. But with Column Expressions it is much more fun :slight_smile:

1 Like

I think you can do it directly from math formula with round($inputcolumn$/0.5,0)*0.5.

4 Likes

That is actually a very compact and beautiful solution!

1 Like

Nice one @lucian.cristian :wink:
Ivan

Brilliance lies in it simplicity. Fantastic, thanks!

Evert

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.