Working with multiple data sets

Hi,

I’m getting two sets of data via API calls and want to create a third data set by taking the difference of the values where the IDs match.
I’ve been looking at using csv or data store modules but couldn’t figure out whats the most common/intended make approach for scenarios like this.
In the end, the new data set should consist of the two columns ID and difference.

Welcome to the Make community!

To answer your question, yes it can be done. To provide an answer with example, we need more information.

Please provide the output bundles of both modules by running the scenario (you can also get this without re-running your scenario from the History tab).

Click on the white speech bubbles on the top-right of each module and select “Download input/output bundles”.

A. Upload as a Text File

Save each bundle contents in a plain text editor (without formatting) as a bundle.txt file.

You can upload the file here by clicking on this button:

B. Insert as Formatted Code Block

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles.
These are the two ways to format text so that it won’t be modified by the forum:

  • Method 1: Type code block manually

    Add three backticks ``` before and after the content/bundle, like this:

    ```
    content goes here
    ```

  • Method 2. Highlight and click the format button in the editor

Providing the input/output bundles will allow others to replicate what is going on in the scenario, especially if there are complex data structures (nested arrays and collections) or if external services are involved.

This will allow others to better assist you. Thanks!

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Hi samliew, thanks a lot for the feedback!

After the API call I’m using a JSON parser after which the data for both will look like this (since the data is sensitive this is a small dummy collection but in the correct format):

[
    {
        "collection": [
            {
                "Messages": null,
                "Series": [
                    {
                        "columns": [
                            "time",
                            "last"
                        ],
                        "name": "X",
                        "tags": {
                            "device_name": "00000001"
                        },
                        "values": [
                            [
                                "2025-02-18T05:20:45.111Z",
                                97313.52
                            ]
                        ]
                    },
                    {
                        "columns": [
                            "time",
                            "last"
                        ],
                        "name": "X",
                        "tags": {
                            "device_name": "00000002"
                        },
                        "values": [
                            [
                                "2025-02-18T05:28:00.855Z",
                                1193.68
                            ]
                        ]
                    }
                ]
            }
        ]
    }
]

where “device_name” is the ID and the second entry in “values” is the value I want to substract for matching IDs.

What is the example output given this input you provided?

This would be the ouptut of a JSON parser.
Lets say the other API call and JSON parser also has an entry where device_name = 00000002, with da differenat date/value pair:

                    {
                        "columns": [
                            "time",
                            "last"
                        ],
                        "name": "X",
                        "tags": {
                            "device_name": "00000002"
                        },
                        "values": [
                            [
                                "2025-02-25T05:28:00.855Z",
                                1200.68
                            ]
                        ]
                    }

Then i want the resulting data structure to include the pair device_name: 00000002, value: 7

Welcome to the Make community!

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

This is just an example. Your final solution may or may not look like this depending on your requirements.

Module Export - quick import into your scenario

You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.

  1. Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:

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

  3. Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.

JSON module export — paste this directly in your scenario

{"subflows":[{"flow":[{"id":419,"module":"json:ParseJSON","version":1,"parameters":{"type":""},"mapper":{"json":"[\n    {\n        \"collection\": [\n            {\n                \"Messages\": null,\n                \"Series\": [\n                    {\n                        \"columns\": [\n                            \"time\",\n                            \"last\"\n                        ],\n                        \"name\": \"X\",\n                        \"tags\": {\n                            \"device_name\": \"00000001\"\n                        },\n                        \"values\": [\n                            [\n                                \"2025-02-18T05:20:45.111Z\",\n                                97313.52\n                            ]\n                        ]\n                    },\n                    {\n                        \"columns\": [\n                            \"time\",\n                            \"last\"\n                        ],\n                        \"name\": \"X\",\n                        \"tags\": {\n                            \"device_name\": \"00000002\"\n                        },\n                        \"values\": [\n                            [\n                                \"2025-02-18T05:28:00.855Z\",\n                                1193.68\n                            ]\n                        ]\n                    }\n                ]\n            },\n{\n                \"Messages\": null,\n                \"Series\": [\n                    {\n                        \"columns\": [\n                            \"time\",\n                            \"last\"\n                        ],\n                        \"name\": \"X\",\n                        \"tags\": {\n                            \"device_name\": \"00000001\"\n                        },\n                        \"values\": [\n                            [\n                                \"2025-02-18T05:20:45.111Z\",\n                                97313.52\n                            ]\n                        ]\n                    },\n                    {\n                        \"columns\": [\n                            \"time\",\n                            \"last\"\n                        ],\n                        \"name\": \"X\",\n                        \"tags\": {\n                            \"device_name\": \"00000002\"\n                        },\n                        \"values\": [\n                            [\n                                \"2025-02-18T05:28:00.855Z\",\n                                1193.68\n                            ]\n                        ]\n                    }\n                ]\n            }\n        ]\n    }\n]"},"metadata":{"designer":{"x":312,"y":-3381,"name":"Array 1"},"parameters":[{"name":"type","type":"udt","label":"Data structure"}]}},{"id":420,"module":"json:ParseJSON","version":1,"parameters":{"type":""},"mapper":{"json":"[\n    {\n        \"collection\": [\n            {\n                \"Messages\": null,\n                \"Series\": [\n                    {\n                        \"columns\": [\n                            \"time\",\n                            \"last\"\n                        ],\n                        \"name\": \"X\",\n                        \"tags\": {\n                            \"device_name\": \"00000002\"\n                        },\n                        \"values\": [\n                            [\n                                \"2025-02-25T05:28:00.855Z\",\n                                1200.68\n                            ]\n                        ]\n                    }\n                ]\n            }\n        ]\n    }\n]"},"metadata":{"designer":{"x":566,"y":-3379,"name":"Array 2"},"parameters":[{"name":"type","type":"udt","label":"Data structure"}]}},{"id":421,"module":"builtin:BasicFeeder","version":1,"parameters":{},"mapper":{"array":"{{419.collection[].Series}}"},"metadata":{"designer":{"x":811,"y":-3378}}},{"id":422,"module":"util:TextAggregator","version":1,"parameters":{"rowSeparator":"","feeder":421},"filter":{"name":"matching ids","conditions":[[{"a":"{{map(420.collection[].Series; \"tags.device_name\")}}","o":"array:contain","b":"{{421.tags.device_name}}"}]]},"mapper":{"value":"device_name: {{421.tags.device_name}}, value: {{abs(parseNumber(last(last(421.values)); \".\") - parseNumber(last(last(last(map(420.collection[].Series; \"values\"; \"tags.device_name\"; 421.tags.device_name)))); \".\"))}}"},"metadata":{"designer":{"x":1116,"y":-3378,"messages":[{"category":"last","severity":"warning","message":"A transformer should not be the last module in the route."}]},"parameters":[{"name":"rowSeparator","type":"select","label":"Row separator","validate":{"enum":["\n","\t","other"]}}]}}]}],"metadata":{"version":1}}

Note: Did you know you can reduce the size of blueprints and module export code like the above, using the Make Blueprint Scrubber?

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.