Trouble getting distinct results (SOLVED)

@bill65358 My apologies for not testing out the suggested code. The example that I have in one of my projects is a little different than this where I was merging the aggregate data with some other data.

The problem with the above code is that repeaters require a unique “_id” value that does not have spaces in any of the values. Almost every one of the items above does have spaces. What to do?

The Javascript map function can solve the problem. The idea is to create a new array that has a unique _id value along with the data that the repeater needs to display. This is the .then portion of the code above modified with the map function.

 .then((results)=>{                                     
    let index = 0;
    const newArray = results._items.map(item => {
        const newItem = {};
        index++;
        newItem._id = index.toString();
        newItem.name = item.name;
        newItem.count = item.count;

        return newItem;
     })
     // now assign the newly formed array to the repeater
     $w("#repeater").data newArray;
     $w("#repeater").show();
 }); 

I’m not sure why aggregate functions have an underscore before items with results._items. Straight wixData queries have it in the form of results.items.

It’s getting there …