Get length of arrays which are not empty – How To


Hello everyone,

I have a repeater module that I would like to repeat depending on the number of values in the array that are not empty (the array length is 10, however the number of values that are not empty can vary from 1-10)

I have tried this formula in a repeater module : {{length(1.Entry-Name != “”)}} however it is outputting length of 4, when based on the input, it should be outputting 2.

Any suggestions on the correct formula for this would be a great help thank you.

Screenshot 2024-07-28 at 22.50.24

The better answer is do not use a repeater module at all.

When there is an ARRAY, think ITERATOR.

Then, you can remove empty strings from an array with the built-in function remove

e.g.:

{{ remove(1.array; emptystring) }}

Screenshot_2024-07-29_100705

Output:

Screenshot_2024-07-29_100721

For more information, see the function 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

Hope this helps!

samliewrequest private consultation

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



1 Like

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.

Click to Expand Module Export Code

JSON – Copy and Paste this directly in the scenario editor

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 89,
                    "module": "builtin:BasicFeeder",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "array": "{{remove(1.array; emptystring)}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 234,
                            "y": -2769
                        },
                        "restore": {
                            "expect": {
                                "array": {
                                    "mode": "edit"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "array",
                                "type": "array",
                                "label": "Array",
                                "mode": "edit",
                                "spec": []
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

samliewrequest private consultation

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

Hi @hb ,

Welcome to Make Community!

Please check the below images and notes.
Input Array:-

Length Function:-

Output :-
image

{{length(remove(1.array; emptystring))}}

Please use this function in the repeater to get the length of a non-empty array.

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
| Book Live Implementation
Visit us here
Youtube Channel



Source link

Leave a Comment