How to return number dropdown value?

I hope this will make sense
I am trying to build up a simple database filter.
Mix of numbers and text elements.Text works fine,numbers I get this error

Failed to perform query on [ForSale].
WDE0058: $gte should be a Date, Number, or String. Got null instead
WDE0058: $lt should be a Date, Number, or String. Got null instead

according wix document and researches, this relates to the fact that the dropdown can’t return the value of the number and I need to transform it in order to display it?

Now i tried some solutions can anyone please help?

Here is the piece of code that it is a number value in the database,number value matches in the dropdown value exactly,but it won’t search
I tried .ge , .eq or .contains
Thank you

 
.ge("bathrooms",$w('#dropdown1').value)
 

Try:

.ge("bathrooms", Number($w('#dropdown1').value))

Thank you,i have played around with this but tried it again,with unfortunately the same issue :frowning:
Do you have any other suggestions?I got two number values that return this error,the text values work fine

@mels_design no idea. Maybe the problem is in the other parts of your code that you haven’t posted here.

@jonatandor35 Thank you for your time,i haven’t tought about that as this is the only side that returns a problem,could you have a look at the full code please?

import {wixData} from ‘wix-data’;

export function button1_click(event, $w) {

let searchValue = $w(“#locationSearch”).value;

$w(“#dataset1”).setFilter(wixData.filter()

 .contains('propertyAddress', searchValue) 
 .eq("bathrooms", Number($w('#dropdown1').value)) 
 .eq("bedrooms", Number($w('#dropdown2').value)) 
 .contains("propertyType", $w('#dropdown5').value) 
 .between("purchasePrice", parseFloat($w('#dropdown3').value), parseFloat($w('#dropdown4').value))) 

 .then((results) => { 
  console.log("Dataset is now Filtered"); 
  $w("#repeater1").data = results.items; 
 }) 
 . **catch** ((err) => { 
  console.log(err); 

});

$w(“#repeater1”).expand();

}

export function dropdown5_change(event, $w) {
SubCatFilter();
}
function SubCatFilter (){
$w(“#dropdown6”).enable();

$w(“#dataset2”).setFilter(wixData.filter()

.eq(“typesOfProperties”, $w(“#dropdown5”).value)
);}

Here is a screenshot if help anything

Now I’m confused. I don’t see the .ge() in your full code.

@jonatandor35 if I use ge (greater or equal) or eq i am getting the same error,i use it at this piece of code

.ge(“bathrooms”, Number($w(’ #dropdown1 ‘).value))
.ge(“bedrooms”, Number($w(’ #dropdown2 ').value))

@mels_design I don’t know. But I can see on the screenshot that you have some dropdowns without a selected value. Be sure you’re not querying using these null values.

@jonatandor35 This might be an issue,can you explain me this with some basic language :slight_smile:
I am trying to learn

How I setup the dropdowns,i did not connected them to the database with the database icon,I have setup values,for bathroom is from 0 till 7 and bedroom is 0 till 7,currently I have in the database some test elements and there is a property for each bathroom option.

If you could explain me your sentence and what exactly to look for I would appreciate it much

@mels_design That’s OK. But in your previous screenshot, you selected one of the Bedrooms options (“2”) but non of the bathrooms options. Therefore the value of the Bathrooms dropdown was null. Then you tried to filter using these values, but you cannot use .ge() if the value is null. It must be a certain value.

Thank you,I appreciate that you are trying to help me,i am struggling with this for weeks now and just can’t realise what could be,i have redone it several times and tried different approaches,when I click the dropdown each value matches exactly 100% ,feeling lost,i paid for help a wix pro and could not find the issue

So now that you know what the problem is, and you know you cannot use null value to filter, you can decide to use a default value (for example: greater then 0) in case the dorpdown value is null.

Hi Mel,
I was having this issue also. I ended up setting the “price” in my database as a ‘number’ instead of ‘text.’ Then in my dropdowns I noticed that if I added commas to the prices it was having trouble differentiating the numbers.

For example the choices in my dropdown looked like this → $1,000,1,000 and I had to change them to look like this → $1000,1000

Then everything worked fine! Hope that helps!