# If a number is between X and Y, show A

**URL:** <https://forum.bubble.io/t/if-a-number-is-between-x-and-y-show-a/99942>\
**Category:** Need help\
**Created:** [July 2, 2020, 11:49am UTC](https://forum.bubble.io/t/if-a-number-is-between-x-and-y-show-a/99942 "2020-07-02T11:49:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TedSmokey](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@TedSmokey](https://forum.bubble.io/u/TedSmokey)\
**Post date:** [July 2, 2020, 11:49am UTC](https://forum.bubble.io/t/if-a-number-is-between-x-and-y-show-a/99942/1 "2020-07-02T11:49:17Z")

</div>

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.

 ![Screenshot 2020-07-02 21.00.05](https://us1.discourse-cdn.com/bubble/original/3X/3/a/3aca7723325b6feacb7a2a8c4bdfbb56acbc1ef0.png)

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.

---

<div class="post-metadata">

**Author:** ![joao1997domingues](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/joao1997domingues/32/65430_2.png) [@joao1997domingues](https://forum.bubble.io/u/joao1997domingues)\
**Post date:** [July 2, 2020, 2:44pm UTC](https://forum.bubble.io/t/if-a-number-is-between-x-and-y-show-a/99942/2 "2020-07-02T14:44:16Z")

</div>

Hi @TedSmokey and Welcome to this forum 😃

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](https://us1.discourse-cdn.com/bubble/original/3X/c/3/c397f233d956ef420a71c06b1a1afb90f60aca64.png)

> **Then, you can save those values using for example a Slider Input element**
>
> ![image](https://us1.discourse-cdn.com/bubble/original/3X/0/5/05a390f8253a41f857c3d48ea8e892623ccb7f57.png)

> **And then it's easy to search for the record that matches the value like this**
>
> ![image](https://us1.discourse-cdn.com/bubble/original/3X/5/2/520fcb3d7d102eb0198b2ece7ea102e894d158ee.png)

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

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

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

Nice Bubbling!

---

<div class="post-metadata">

**Author:** ![TedSmokey](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@TedSmokey](https://forum.bubble.io/u/TedSmokey)\
**Post date:** [July 2, 2020, 11:23pm UTC](https://forum.bubble.io/t/if-a-number-is-between-x-and-y-show-a/99942/3 "2020-07-02T23:23:46Z")

</div>

@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](https://us1.discourse-cdn.com/bubble/original/3X/c/4/c4b58cb22d4cc1da9d5b0f3d63ca067b5fc7cc13.png)

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.

 ![Screenshot 2020-07-03 09.10.53](https://us1.discourse-cdn.com/bubble/original/3X/a/9/a97751c12310f6aca33bfc59afb12d3326730f7f.png)

 ![Screenshot 2020-07-03 09.11.04](https://us1.discourse-cdn.com/bubble/original/3X/2/8/28c8483546200dbc4281bfbd83f9779b2d12de6f.png)

 ![Screenshot 2020-07-03 09.12.34](https://us1.discourse-cdn.com/bubble/original/3X/b/0/b05d86137db2fcee7446e4a1b338ecc8fe576532.png)

1. Here’s the workflow:

 ![Screenshot 2020-07-03 09.13.46](https://us1.discourse-cdn.com/bubble/original/3X/e/3/e35c56360c5a461b27fa7a857bc1436b43b45e72.png)

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)

 ![Screenshot 2020-07-03 08.58.40](https://us1.discourse-cdn.com/bubble/original/3X/8/c/8cf65b69c508d7898dc68cac51213359fbcb35c0.png)

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](https://us1.discourse-cdn.com/bubble/original/3X/0/a/0a6b8ae7867b6d9d87a229bebf936b20659f20f6.png)

---

<div class="post-metadata">

**Author:** ![joao1997domingues](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/joao1997domingues/32/65430_2.png) [@joao1997domingues](https://forum.bubble.io/u/joao1997domingues)\
**Post date:** [July 3, 2020, 12:08am UTC](https://forum.bubble.io/t/if-a-number-is-between-x-and-y-show-a/99942/4 "2020-07-03T00:08:12Z")

</div>

Glad I helped @TedSmokey!!

Nice bubbling 😃

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [September 10, 2020, 11:49am UTC](https://forum.bubble.io/t/if-a-number-is-between-x-and-y-show-a/99942/5 "2020-09-10T11:49:20Z")

</div>

Closed on September 10, 2020, 11:49am UTC

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