Summarize Numbers from Birthday

Hello Community,

I need to summarize birthday dates 1980-07-08 for example
(IF the end result is double digit = then summarize again)

I do a 5x Variable Math but might someone know a nested formula or another workarround.

1980-07-08 = 1+9+9+9+0+7+0+7 = 33 = double digit so again a match with IF= correct 6

Processing: Google Chrome2024-08-02 at 11.52.31@2x.png…





Welcome to the Make community!

What are you trying to do here? What’s the formula about?

I think your example has an error, and this part is confusing: “double digit so again a match with IF= correct 6

Can you link to somewhere that explains what you are trying to achieve?

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

Hello Samliew

I receive from form birthdates 1990-08-12 and at the end i need to summarize the numbers like
1+9+9+0+0+8+1+2 = 30 if the number is 2digit i need to summarize again = 3

I did all the work, how ever as you see i need 4 modules for that might i can nest the formulas.

Thank you

Welcome to the Make community!

Yes, that is possible. I highly recommend using the CustomJS integration for this to save on operations.

Screenshot_2024-08-09_220841

You’ll need a minimum of one “Execute Inline JavaScript Code” module:

Example Input/Output

Screenshot_2024-08-09_220850

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

  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.

Click to Expand Module Export Code

JSON - Copy and Paste this directly in the scenario editor

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 190,
                    "module": "custom-js:inlineexecutev2",
                    "version": 1,
                    "parameters": {
                        "__IMTCONN__": 2457341,
                        "jscode": "function calcSumOfDigits(text) {\n  let res = text.split('').reduce((a, c) => {\n    const num = Number(c);\n    return isNaN(num) ? a : a + num;\n  }, 0).toString();\n  return res.length > 1 ? calcSumOfDigits(res) : Number(res);\n}\nreturn calcSumOfDigits(input);",
                        "returnValueType": "text"
                    },
                    "mapper": {
                        "input": "{{216.date}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 3275,
                            "y": -3969
                        },
                        "restore": {
                            "parameters": {
                                "__IMTCONN__": {
                                    "label": "My CustomJS V2 connection",
                                    "data": {
                                        "scoped": "true",
                                        "connection": "custom-js2"
                                    }
                                },
                                "returnValueType": {
                                    "label": "Text"
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "__IMTCONN__",
                                "type": "account:custom-js2",
                                "label": "Connection",
                                "required": true
                            },
                            {
                                "name": "jscode",
                                "type": "text",
                                "label": "JavaScript Code",
                                "required": true
                            },
                            {
                                "name": "returnValueType",
                                "type": "select",
                                "label": "Return Type",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "text",
                                        "collection",
                                        "array",
                                        "binary"
                                    ]
                                }
                            }
                        ],
                        "expect": [
                            {
                                "name": "input",
                                "type": "text",
                                "label": "Input"
                            }
                        ],
                        "interface": [
                            {
                                "name": "output",
                                "type": "text",
                                "label": "Output"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

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

@samliew

How to set-up a FREE Custom JS connection?

  1. Go to the app’s website and click “Create Account”.

  2. Once logged in, on the right-hand side, click on the “Show” link. Copy the API key.

  3. Click “Create a connection” in the Custom JS module:

  4. Paste API key and click Save:

How to use the Custom JS module?

  1. Map a variable (or a JSON object) into the “Input” field.

  2. Write a function to do something with the input variable. If the input is a JSON, you can reference object properties using dot notation.

  3. Write a final statement to return the call of the function you wrote.

Further Information

If you need help with using Custom JS modules, please create a new thread. This helps keep the forum organized and helps me get to your question faster.

You can also take a look at the official documentation here for more advanced usage: