Filter data between two cells

I would like to Datafilter my dataCollection so that I only forward data as long as cell ”A”=(4) is greater ”>” than cell ”B”=(3). Different numbers appear in the cells, but it is always cell “A” that must be greater than cell “B”

*I have tried with this code, I hope someone can help.

import wixData from ‘wix-data’;
function filter(DB1) {
$w(DB1).setFilter( wixData.filter()
.eg (“A”, ”B”)

I don’t think this can be done using this approach - since .ge will take a field within the collection you want to filter and filter according to a value that you set during getting the data.

You’ll likely need an approach to get the data from the collection using .query() - - and then process the data after.

This isn’t the exact code you’ll need but is likely the essence of it:

import wixData from 'wix-data';

let data = wixData.query("CollectionID").find()

const filteredData = data.items.filter(item => item.ColumnA > item.ColumnB);

Then this data can be applied to a repeater (which I imagine is what you’re using). The repeater would need connecting via code, however.

What I need to use it for is to control a “DropDown”, so I don’t know if “data.item” can be used for this??.

To populate the values within the dropdown?

Are you able to share more details about the project, what you’re hoping to achieve?

It concerns some players who have been created in a data file no. 1 and have been assigned a number and how many times they must play, cell “A”, so when they have played the winner must report the game. The winner selects their number via the dropdown and their data appears, they enter the opponent’s number via the dropdown, and then points, then the information is saved on a data file no.2. On data file no.1, cell “B” is counted up by 1, so that when “B” reaches cell “A”, the dropdown should not come with the numbers where cell “B” is equal to cell “A”. i.e. as long as cell “A” is interfering with a cell “B”, the player number must appear on the dropdown.
I hope this makes sense.