Aggregation filter in a dynamic page

Hi,

My home page will be a page that the user will select a category and then go in a dynamic page. In that dynamic page, its a table that will take the MAX result of the competitor from an over 5K data collection.

So my first test, was what is working below, if I set up the category manually, it will work. But what I want, is that it will use this page and setup by the click from the previous page. If you need more info, don’t hesitate.

Working :

// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixData from ‘wix-data’
$w.onReady(function () {

let filter = wixData.filter().eq("category", "champ"); 

wixData.aggregate("collCompetitions") 

	.filter(filter) 
	.group("firstname", "lastname") 
	.max("short") 
	.descending("shortMax") 
	.run() 
	.then(res => { 
		console.log(res.items); 

		$w('#table2').rows = res.items; 
	}); 

});

What I want :

// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixData from ‘wix-data’
$w.onReady(function () {

wixData.aggregate($w('#dynamicDataset')) //The Dynamic Dataset will set the category chosen in a previous page 
	.group("firstname", "lastname") 
	.max("short") 
	.descending("shortMax") 
	.run() 
	.then(res => { 
		console.log(res.items); 

		$w('#table2').rows = res.items; 
	}); 

});

That was my 1st post for more information : https://www.wix.com/code/home/forum/community-feature-request/database-find-max-value

I found how to do it.

let donCategorie = $w(‘#dynamicDataset’).getCurrentItem()
let filter = wixData.filter().eq(“categorie”, donCategorie.categorie);