How can I tell when a dataset is finished processing a filter?

I am using a dataset and filter which changes based on which row is clicked in a table (which uses a second dataset). Code is something like:

export function SITMembersTable_rowSelect(event) {
    //console.log("rowSelect detected");
    itemData = event.rowData;
    loadFieldsForRow(itemData);
}
export function loadFieldsForRow(itemData) {
    $w("#emailAddress").value = itemData.email;
    // Filter the purchases history and purchases data sets
    $w("#purchasesdataset").setFilter( wixData.filter()
        .startsWith("memberEmail",$w("#emailAddress").value)
    );
    const currentItem = $w("#purchasesdataset").getCurrentItem();
    if ( currentItem === null) {
        $w("#currentSku").text = "n/a"
        $w("#currentLastActivity").text = "n/a";
        $w("#currentNextRenewal").text = "n/a"
    } else {
        $w("#currentSku").text = currentItem.sku
        $w("#currentLastActivity").text = mapLastActivity(currentItem.lastActivity);
        let renewalDate = new Date(currentItem.expiryTimeMilliseconds);
        $w("#currentLastActivity").text = renewalDate.toString();       
    }
}

The problem I am seeing is that the code evaluating ‘currentItem’ must be executing prior to the dataset being “finalized” with the filter I’ve set, because I’ve tested it when selecting a row that absolutely has purchase data and I still wind up with “n/a” values.

So I am theorizing that the code testing:

 (currentItem === null) 

is executing before the dataset is “done” filtering.

What I think I need is to know when the dataset is “ready” after all filtering is in place in order to execute that code.

Is there a way to do this? Is there another approach I can use to get what I want?

Essentially, what I want is when a user clicks a row in the “users” table I want the related subscription purchase info held in another collection to show.

Well, what I ended up doing was not using a second dataset at all, and simply doing a regular wixData.query() based on the email address of the row the user clicks in the table - relevant portions of the code are:

export function loadFieldsForRow(itemData) {
    $w("#emailAddress").value = itemData.email;
    wixData.query("SITInAppPurchases") 
    // Query the collection for any items whose "Name" field contains  
    // the value the user entered in the input element
    .startsWith("memberEmail", $w("#emailAddress").value)
    .find()  // Run the query
    .then(res => {   
        // Set the table data to be the results of the query 
        if ( res.items.length > 0 ) {
            const currentItem = res.items[0];
            $w("#currentSku").text = currentItem.sku
            $w("#currentLastActivity").text = mapLastActivity(currentItem.lastActivity);
            let renewalDate = new Date(currentItem.expiryTimeMilliseconds);
            $w("#currentNextRenewal").text = renewalDate.toString();
        } else {
            $w("#currentSku").text = "n/a"
            $w("#currentLastActivity").text = "n/a";
            $w("#currentNextRenewal").text = "n/a"
        }
    })
    .catch( (err) => {
        console.log("Got error attempting to find purchase for " +     $w("#emailAddress").value + " error was: " + err);
    }); 
}


This seems to work ok.