How to Round Up to the Nearest 0.5
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
Solved! Go to Solution.
- Labels:
- Expression
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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 🙂
Best,
Fernando Vizcaino
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks Dan! This works marvelously.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This works great! I would not be able to come up with the formulas by my own. Probably need time to digest the methodology.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Have you tried:
ceil([Field1]*2)/2
