Filtering array items based on how often a value occurs

Yes, that is possible. You’ll need a minimum of two modules:

1. Aggregate bundles, group by profileLink

2. Filter at least 3 in array

3. Aggregate to text

Give it a go and let us know if you have any issues!

Output

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

View Module Export Code

JSON

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 6,
                    "module": "json:ParseJSON",
                    "version": 1,
                    "parameters": {
                        "type": ""
                    },
                    "mapper": {
                        "json": "[]"
                    },
                    "metadata": {
                        "designer": {
                            "x": 605,
                            "y": 2
                        },
                        "restore": {
                            "parameters": {
                                "type": {
                                    "label": "Choose a data structure"
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "type",
                                "type": "udt",
                                "label": "Data structure"
                            }
                        ],
                        "expect": [
                            {
                                "name": "json",
                                "type": "text",
                                "label": "JSON string",
                                "required": true
                            }
                        ]
                    }
                },
                {
                    "id": 9,
                    "module": "builtin:BasicAggregator",
                    "version": 1,
                    "parameters": {
                        "feeder": 6
                    },
                    "mapper": {
                        "job": "{{6.job}}",
                        "name": "{{6.name}}",
                        "degree": "{{6.degree}}",
                        "postUrl": "{{6.postUrl}}",
                        "lastName": "{{6.lastName}}",
                        "firstName": "{{6.firstName}}",
                        "timestamp": "{{6.timestamp}}",
                        "companyUrl": "{{6.companyUrl}}",
                        "companyName": "{{6.companyName}}",
                        "profileLink": "{{6.profileLink}}",
                        "reactionType": "{{6.reactionType}}",
                        "followersCount": "{{6.followersCount}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 848,
                            "y": 1
                        },
                        "restore": {
                            "extra": {
                                "feeder": {
                                    "label": "JSON - Parse JSON [6]"
                                },
                                "target": {
                                    "label": "Custom"
                                }
                            }
                        },
                        "advanced": true
                    },
                    "flags": {
                        "groupBy": "{{6.profileLink}}",
                        "stopIfEmpty": true
                    }
                },
                {
                    "id": 12,
                    "module": "util:TextAggregator",
                    "version": 1,
                    "parameters": {
                        "feeder": 9,
                        "rowSeparator": "other",
                        "otherRowSeparator": ","
                    },
                    "filter": {
                        "name": "at least three",
                        "conditions": [
                            [
                                {
                                    "a": "{{length(9.array)}}",
                                    "b": "3",
                                    "o": "number:greaterorequal"
                                },
                                {
                                    "a": "{{9.`__IMTKEY__`}}",
                                    "b": "{{emptystring}}",
                                    "o": "text:notequal"
                                }
                            ]
                        ]
                    },
                    "mapper": {
                        "value": "\"{{9.`__IMTKEY__`}}\":{{length(9.array)}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 1166,
                            "y": 0,
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {
                            "extra": {
                                "feeder": {
                                    "label": "Array aggregator [9]"
                                }
                            },
                            "parameters": {
                                "rowSeparator": {
                                    "label": "Other"
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "rowSeparator",
                                "type": "select",
                                "label": "Row separator",
                                "validate": {
                                    "enum": [
                                        "\n",
                                        "\t",
                                        "other"
                                    ]
                                }
                            },
                            {
                                "name": "otherRowSeparator",
                                "type": "text",
                                "label": "Separator"
                            }
                        ],
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "multiline": true,
                                "label": "Text"
                            }
                        ],
                        "advanced": true
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

samliewrequest private consultation

Join the Make unofficial Discord server!

3 Likes