If a number is between X and Y, show A

I’m trying to display a number based on how many kilometres it equals. Eg if KM value = 2000 what I want to do is show the text 5 as 2000km falls within that range in my database. See below.

Having a range feels like the ideal way to set up my data because there will be quite a lot of possible ranges, probably 0-100, 101-200 etc. I’m just now stuck trying to filter on it and output the correct number. I have the KM value as a custom state and/or url param at the moment as I’ve been fiddling with getting it working.

I’m pretty new to this and might be doing it in a bad way and perhaps staring at it for hours as mushed my brain. Any help is greatly appreciated.

Hi @TedSmokey and Welcome to this forum :smiley:

Bubble lets you do this in a simple way using Ranges.

What you have to do first is to set a field to the type numeric range

image

Then, you can save those values using for example a Slider Input element

And then it's easy to search for the record that matches the value like this

image

Please make sure you’re using “Contains(point)”.

Hope I made it clear, if not feel free to ask again :smiley:

Please leave a like and mark as solution if I solved your problem :smiley:

Nice Bubbling!

2 Likes

@joao1997domingues - Thank you so much! That solved my problem. I was so close yesterday, as I had been trying to use the numeric range field but I couldn’t work out how to enter data from the DB Editor. Using the slider I was able to input the data into the numeric range field.

For other users who come to this post in time, here’s some screenshots of what I did following Joao’s instructions to get it work.

  1. Created a numeric range field type in my custom Data type

Screenshot 2020-07-03 09.27.05

  1. On a new page I inserted a slider input, a text field to show me what those ranges were as I moved the slider, and then a submit button to set up the workflow to submit the data to the correct table and field.

  1. Here’s the workflow:

  1. That submits the ranges to my Data type field I set up in step one called KMRange (the values for each range you can see, 2 & 5, I just manually entered after the range was in there)

  1. Then on the page I want to show the value for that range, I inserted a text box that does a search for the record and uses Contains(point) in the constraints for the search. It gets the K value (which is my Number of KMs) from the URL.

Screenshot 2020-07-03 09.16.16

2 Likes

Glad I helped @TedSmokey!!

Nice bubbling :smiley:

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