Finding closest decimal to another decimal

Hello!

I’ve been having a bit of trouble finding the number closest to another number in a set of decimals.

Basically say I have 5.4, I am currently filtering it to the first number under 5.4 to get the closest number. However, suppose there is 5.6 and 1.4 in the data set, it will just pick 1.4 because of this filtering.

Rounding feels a bit limited here for me as well.

Any thoughts on if there a way to pick the number closest to the decimal that I want? E.g. the 5.6 in stead of the 1.4? Thanks.

Maybe there’s a more elegant situation, but you could find the closest number under 5.4, then find the closest number greater than 5.4 and do a few steps of basic subtraction to figure out which is closer.

Keith’s List Popper and Friends (SSAs) Plugin | Bubble (FLOW State Single SSA action) can help you temporarily store the difference values within the workflow to figure out which is closer. If you haven’t used it, it’s like a custom state on an element but temporary and just in the workflow.

1 Like

Here’s one way to do it that doesn’t require any plugins or custom JavaScript…

Closest Number (bubbleapps.io)

3 Likes

Bubble wasn’t designed for this task :rofl: