Text that displays number of results of user searches and filters

I have a database of musical theatre repertoire. I have added search and filter functions for the user. I also have text at the top of the page that displays the number of items in the database. I would like that number to change to reflect the number of search and filter results. I would appreciate any help with this!

Here is the database url: https://beverlyrosethompso.wixsite.com/rep-genie/rep-genie

This is the current code for the search results text:
.then((num) => {
let resultsNum = num;
$w(“#SearchCount”).text = resultsNum.toString();


No need for another query, since you are filtering you can just count the items in the dataset after you are done filtering ( .then() ).

At around line 100 you have a .setFilter on your dataset, add a .then and get the total count, then just put this value as the text of the text box

It would look like this:

$w('#dataset1').setFilter(newFilter).then((num) => {
  console.log($w('#dataset1').getTotalCount(), "heres count");
  $w('#SearchCount').text = $w('#dataset1').getTotalCount().toString();


That worked perfectly, thank you!

Anytime, Beverly :)!

Hi Majd Qumseya

May I get some help with this same issue. I have tried the code you provided above. But it doesn’t work for me. I have posted this questions but still no help. Once the user filtered their search I want to display on the page how many results in the category the user choose. User can filter by category, then by City & State.
I have created a text box to display the # of results called searchcount. and a Category button to display the current category the user has chosen, next the City& State button the user has chosen. and a clear all to clear the searches.

Below is my code that I am currently using for my filtered search:

import wixData from ‘wix-data’;

$w.onReady( function () {

export function searchbutton_click_1(event, $w) {

    .contains("category", $w('#vendordropdown').value) 
    .contains("cityState", $w('#cityandstatedropdown').value) 
).then((results) => { 

let count = $w(“#dataset2”).getTotalCount();
if (count === 0){
if (count >= 1) {

      console.log("Dataset2 is now filtered");            

let numberOfResults = $w(“#dataset2”).getTotalCount();
console.log(numberOfResults );
}). catch ((err) => {

this is what my page looks like …

I would appreciate any help that you offer. Thank you

Hello Eb,

Please create a separate ticket for this problem and one of the Wix Employees will get around to it