let filteredTable = $w('#dataset3').setFilter(wixData.filter() .le("minColumn", number) .ge("maxColumn", number))
I want to get the first value of each of those columns.
So something like (aware this doesn't work but just to show roughly what I'd like).
minColumnValue = filteredTable["minColumn"][0]
Bonus code showing how to find the min and max values of the field num (that's the Field Key) in a collection:
$w.onReady(async function () { let results = await wixData.query("NumberList").limit(1000).find(); let items = results.items; let min_num = getMinNum(items); console.log(min_num); let max_num = getMaxNum(items); console.log(max_num); }); function getMinNum(items) { return items.reduce((min, item) => item.num < min ? item.num : min, items[0].num); } function getMaxNum(items) { return items.reduce((max, item) => item.num > max ? item.num : max, items[0].num); }
Note 1: This might not be the most efficient method if you have a large number of items.
Note 2: You will need to have some programming knowledge for this method.
See the documentation for reduce() for more information.
Not 100% sure what you're looking for, but to find the smallest value of a column (field in a collection), you can just sort ascending on that column - then the first row contains the smallest value for that column.
BTW - you should refer to the setFilter() API to see how to properly filter a dataset.