Arrays duplicate

Hello, I’m stuck on a topic.
I have a Table or I have a list of clients, which may be identical but the tagnames field is different,

I would like this to return a single array with all the tags corresponding to this person, like this example:

How would you do? thank you

If you want to create a new data structure based on unique values like the name field in your example, you can use something like const unique_names = [...new Set(test.map(item => test.name))];. You can then loop through your unique values, filter items and build your result set as needed.

Check out the example posted over here to see this piece in a workflow context.

Hello @MutedJam ,

Thank you for your answer,
that’s almost what I want, but I don’t want to cumulate the results but create new fields with the data that there are duplicates, here is the example, my API return is Table1, and this I want to have at the end is Tableau2

var Tableau1 = [{
    "id": "2xjr7m8",
    "Tag": "1"
}, {
    "id": "2xjr7m8",
    "Tag": "2"
}, {
    "id": "2xjr7m8",
    "Tag": "3"
}, {
    "id": "esdffssef",
    "Tag": "1"
}];

var Tableau2 = [{
    "id": "2xjr7m8",
    "Tag1": "1",
    "Tag2": "2",
    "Tag3": "3"
}, {
    "id": "esdffssef",
    "Tag": "1"
}];

Hi @Larmier_Anthony, I understand this isn’t exactly what you want but it would be a starting point. As for adding properties such as Tag1, Tag2, for each item etc. check out this snippet:

Let me know if you run into any trouble with this.

1 Like

I would leave the tags as an array (Function: Line 10) - it’s easier to work with. But if you need split into individual attributes for n8n:

2 Likes

Thanks to you two ! @MutedJam @BillAlex

2 Likes