Multiple Outputs in Switch Case Module

Hello Makers, I need your help with this issue I’m having.

So I’m using a Switch Module and I’ve set up multiple cases. Currently the Switch is only outputting one output from my multiple cases even tho all of my cases passed the condition. Here’s a screenshot.

So my input is a date (2024-07-13)
And I’ve setup the patterns to my cases to be that date as well (2024-07-13) hoping that it would output all three.

(In a bigger perspective, there is a possibility of multiple cases passing the condition/pattern and I want all of those that passed the condition to output. Is this possible? and how?)

Thank you

That’s how the switch module works. The next option will only be reached and “tested” when the previous pattern doesn’t match.

For more information, see the module’s documentation in the Help Center.

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

Articles & Videos

samliewrequest private consultation

Join the unofficial Make Discord server to chat with other makers!

1 Like

I see, is there any module here that does what I was looking for?

You can have an array of collections, but this goes into an Iterator module.

Then, followed by a filter, where you perform the “matches”, and only allow them through if it is what you want.

Then you use an Array Aggregator module to combine the “results” back into an array.

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

This is awesome! Thank you! Will try this and come back to mark this as solved! Thank you!

Hi @Multiply_Advisors
If you can share the screenshot of how you setup the switch module we can further assist you.

Regards,
Msquare Automation - Gold Partner of Make

Free Consultation | Live Implementation

Visit us here | Youtube Channel

1. Create array of collections

Screenshot_2024-07-03_160758

2. Iterate array

Screenshot_2024-07-03_160723

3. Add filter

(example shows “2024-07-14”, matching two of the inputs)

Screenshot_2024-07-03_160723

4. Aggregate results

Screenshot_2024-07-03_160732

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

3 Likes

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": 54,
                    "module": "json:ParseJSON",
                    "version": 1,
                    "parameters": {
                        "type": ""
                    },
                    "mapper": {
                        "json": "{\"cars_array\": [\n  {\n    \"pattern\": \"2024-07-13\",\n    \"output\": \"Mercedes\"\n  },\n  {\n    \"pattern\": \"2024-07-13\",\n    \"output\": \"Ford Credit 1234\"\n  },\n  {\n    \"pattern\": \"2024-07-14\",\n    \"output\": \"Ford Credit 5678\"\n  },\n  {\n    \"pattern\": \"2024-07-14\",\n    \"output\": \"Mercedes Sprinter\"\n  }\n]}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 10,
                            "y": -1094
                        },
                        "restore": {
                            "parameters": {
                                "type": {
                                    "collapsed": true,
                                    "label": "Choose a data structure"
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "type",
                                "type": "udt",
                                "label": "Data structure"
                            }
                        ],
                        "expect": [
                            {
                                "name": "json",
                                "type": "text",
                                "label": "JSON string",
                                "required": true
                            }
                        ]
                    }
                },
                {
                    "id": 55,
                    "module": "builtin:BasicFeeder",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "array": "{{54.cars_array}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 257,
                            "y": -1088
                        },
                        "restore": {
                            "expect": {
                                "array": {
                                    "mode": "edit"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "array",
                                "type": "array",
                                "label": "Array",
                                "mode": "edit",
                                "spec": []
                            }
                        ]
                    }
                },
                {
                    "id": 56,
                    "module": "builtin:BasicAggregator",
                    "version": 1,
                    "parameters": {
                        "feeder": 55
                    },
                    "filter": {
                        "name": "match?",
                        "conditions": [
                            [
                                {
                                    "a": "{{55.pattern}}",
                                    "o": "text:equal",
                                    "b": "2024-07-14"
                                }
                            ]
                        ]
                    },
                    "mapper": {
                        "output": "{{55.output}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 553,
                            "y": -1088,
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {
                            "extra": {
                                "feeder": {
                                    "label": "Iterator"
                                },
                                "target": {
                                    "label": "Custom"
                                }
                            }
                        }
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

1 Like

Thank you! This worksss!!

2 Likes

No problem, glad I could help!

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

4. Do join the unofficial Make Discord server for live chat and video assistance

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!