Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to Round Up to the Nearest 0.5

thaodinh95
8 - Asteroid

Is there a way to round up a number to the nearest 0.5? For example:

0.18 -->0.5

0.46 -->0.5

1.87 -->2

1.17 --> 1.5

 

I tried round(value, 0.5) but it only round to the nearest 0.5. 0.18 --> 0 and 1.17-->1.0

5 REPLIES 5
fmvizcaino
17 - Castor
17 - Castor

Hi @thaodinh95 ,

 

From what I know, there is no direct way of calculation what you need, but we have a workaround using a few expressions 🙂

fmvizcaino_0-1617122611384.png

 

 

 

Best,

Fernando Vizcaino

danilang
19 - Altair
19 - Altair

Hi @thaodinh95 

 

Try this exprsssion

if [Field1]-floor([Field1]) in (0,0.5) then
	[field1]
else
	round([Field1]+.25,0.5)
endif

It handles the special cases of when the number has no decimal or ends in 0.5 by returning the number.  If it's not one of these, the +.25 pushes the number into the proper range to have the internal Round() function work properly

 

Dan

thaodinh95
8 - Asteroid

Thanks Dan! This works marvelously.

thaodinh95
8 - Asteroid

This works great! I would not be able to come up with the formulas by my own. Probably need time to digest the methodology.

apathetichell
18 - Pollux

Have you tried:

ceil([Field1]*2)/2

 

 

Labels