# Buscar informação em um range - search in range value

Preciso buscar uma informação em um range, exemplo, tenho tabela de preços,
01 a 10 kg custa 10,00, de 11 a 20 kg custa 15,00, quero buscar no range certo o valor, tipo se colocar 9 kg, quero que ele traga 10,00

I need to look for information in a range, for example, I have a price list,
01 to 10 kg costs 10.00, 11 to 20 kg costs 15.00, I want to look for the value in the right range, like if I put 9 kg, I want it to bring 10.00

There may be a more elegant solution to this but you could make a data type (let’s call it Costs) with weight as one field and cost as another field. Then you could make the records:
1 kg: 10
2 kg: 10
3 kg: 10

9 kg: 10
10 kg: 10
11 kg: 15
12 kg: 15

20 kg: 15
etc

Then do a search for Costs with a constraint = user input. If the user enters in a number like 10.4 kg then you just round up or down, depending on the logic you want. You also likely don’t have to even be as specific as having a record for every integer. You could likely get the logic you want by doing:
0 kg: 10
10 kg: 15
20 kg: 20
And then use the rounded to function. Only issue is you don’t want to round to a number of decimal places, you want to round down to the nearest multiple of 10, and based on the documentation for “rounded to” you would need to put a negative number which I don’t know if it accepts or not.

I understand, but it would be like this I have a weight range where the value is the same, example 01 to 10 kg, the value is 5.00 ,
11 to 50 kg, value is 7.00 so the search is done when the user launches the weight, then he checks at what interval the weight is and get the value.
example if the guy types 9 kg, the system searches in the range 01 to 10 then it picks up and displays 5.00, another example if he types 14 kg, it takes the value from the range 11 to 50 kg, which would be 7.00 and exists in the input

Yes, I understand. My solution gives you what you want.

Thanks for your help, but I’m going to have to study a lot yet, to do this kind of thing, I’m new to the bubble so it sounds simple but for those starting out it’s complex.

I understood that I have to create two fields in the database so far, ok, but in the search I didn’t understand what to do, with doing this validation of the search of less than or equal… how to make the search go through the interval. this I did not understand.

Create the data type called costs with two fields called Costs. One for price and one for weight and fill out the data how I described above.
click “do a search for” and then in the popup window and choose Costs. Then, you make a constraint in that popup window that says weight = input A’s value (or whatever method you have to accept the user input).
Then close this window and click the more button after the words “search for Costs” and click “'s price” and then click the more button and click “:first item”

is anything else missing??

You have to match data types. In your database, what is price data type set to? This should be set as number. Also, on your input price field, you need to set that type as number as well. The reason you are seeing red is because the data types are not the same.

Bubble isn’t intelligent like that. Any time data is sent anywhere from one place to another, you have to have the origin and the destination data types match. If they don’t, bubble will give you that red text.

Also, carefully reread my instructions. You haven’t followed them correctly.

unfortunately I couldn’t, but thanks for the help.

You couldn’t what?

You have the constraint set as price but it needs to be set as weight

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