Return the latest field from a collection

HI,

I have a collection where by its populate by my clients using a form. one of the fields in this form is “Weight In KG” what i want to be able to do is create meal plans for the clients.

When i start creating the meal plan i have a drop down that populates all my clients names and i choose one, in the example i choose myself “Daniel Whittaker” what i want the meal plan to then do is scan this collection find the latest date that Daniel Whittaker checked in and return the associated Weight In KG value to a text box in my meal plan im creating.

I have the drop down working and can get the drop down to get the email address of the client easy enough but struggling to find a way to have it look for the selected clients name and the latest Weight In KG entry.

In the screen shot shown the latest entry for Daniel Whittaker is 20/4/2021 and he weighed 97.4 kg so id like that 97.4 kg to show in my form some how.

Below is the code linked to the clients name drop down that populates their email address
as you can see this is taken from the private members collection. Some how i need to add to the code to say ok this is the clients email address lets look for the latest entry in collection “My Check ins” find that email address and return the latest dates Weight in KG value as shown above. So in this example it should return 97.4

// Client dropdown change functions
 export function ClientNamedropdown_change(event) {
      return wixData.query("Members/PrivateMembersData")
      .eq("name",$w('#ClientNamedropdown').value)
      .find()
      .then( (results) => {
 let items = results.items;
 let item = items[0];
 let email = item.loginEmail;
 let firstName = item.firstName;
 let fullName = item.name;
      $w("#emailAddresstext").show("fade", fadeOptions);    
      $w('#emailAddresstext').text = item.loginEmail.toString();
      $w('#firstNametext').text = item.firstName.toString();
      console.log("Name = ", fullName);
      console.log("Email address = " ,email,);
      })
      .catch( (err) => {
 let errorMsg = err;
       console.log(errorMsg);    
      }  
   )}

Thanks and regards

Dan