Can an MROUND Excel function be created in Bubble?

In Excel there is a function called MROUND

This allows one to round to a specific multiple, rather than being limited to only 10, 100, 1000, etc

For example, setting the multiple to 25, with an input of 114, results in 125

Is this possible in Bubble?

You can do it stepwise. In the case of 25, you would multiply by 4, then round, then divide by 4.

So 114*4=456, which rounds to 500, divided by 4=125.

@edd so how did you come by the 4? And will 4 work for every number?
If the number was 112 you will expect the result to be 100.
Using your formula : round(4*112)/4 = 112 instead of the correct answer of 100.

This is a formula that will always work:
round(number/multiplier)*multiplier

In bubble you can write the expression as this
image

Here Input num contains the number to convert.
Input multiplier contains the multiplier value.

1 Like

Sorry, I happened to catch the question quickly on my phone and just wanted to let OP know it was possible, so my answer was hasty. In any case, 4 is used along with round to nearest 100 because he wanted to hard code a round to nearest 25. So 112*4 rounds to 400, divided by 4 = 100.

Though of course yours is more elegant. You get my upvote!

Brilliant solution. Thank you!

This topic was automatically closed after 70 days. New replies are no longer allowed.