I’m having a very difficult time figuring out the ROUND function syntax.
USE CASE: I have a static spreadsheet in Excel where I use the MROUND function to make medication volumes end in either a zero (X.0), 5/10ths (X.5) or 5/100ths (X.X5) for easy administration. That formula is “=MROUND(“cell #”), 0.X” with the X having as many or as few zeroes as needed to round where I need it to. I’ve tried multiple ways to get this to work in the Editor but I can’t quite get it right. I’m attempting to emulate the spreadsheet with a live calculator in my app but I’m losing this battle.
Can someone please please help???
can you share your sheet data
Haven’t encountered MROUND before, so I had to look it up.
According to the doc, its function is slightly different from how you describe it.
That is, the 0.X in your example has nothing to do with the number of zeros, but is rather the multiple that the number should be rounded to. So for example, if you specify 0.07 then the number should be rounded to the nearest multiple of 0.07.
The ROUND function in Glide just allows you to specify the number of decimal places to round the result to, so it’s not quite the same.
To get the same as you would with MROUND will probably require a slightly more complex formula combining both MOD and ROUND.
I’ll have a fiddle with it…
A standard round should work for your X.0 case
This should round to the nearest quarter
This should round to the nearest half and would work for your X.5 case.
This should work for your X.X5 case.
Still wrapping my head around it, but looks promising.
Factor * Round(Number/Factor)
Looks correct, I think?
Yeah, I think I like @Darren_Murphy’s method better. Seems to make more sense than the way I did it.
@Jeff_Hager and @Darren_Murphy - you dudes are the best!! Thank you for always coming up with the right answers, quickly!!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.