Lists

Built-in step · 24 steps

Count, sort, combine, and clean up lists and records.

Steps

StepWhat it does
Add item to endAdd an item to the end of a list.
Check if list includes itemCheck whether a list includes a specific item.
Combine two listsMerge two lists into one, keeping the items of the first list followed by the items of the second.
Compare two listsFind what two lists have in common and where they differ: what is only in the first, only in the second, in both, and, for records matched by a field, which ones changed.
Count different valuesCount how many different values a list holds, or how many different values one field takes, like how many customers placed the orders.
Count itemsCount how many items are in a list.
Create a listCreate a list by entering its items one by one.
Edit a recordKeep only some fields of a record, remove fields, rename them, or merge in another record.
Filter listKeep only the items in a list that match a condition, and return them as a new list.
Find item positionFind where an item appears in a list.
Get first itemGet the first item of a list.
Get last itemGet the last item of a list.
Get one field from every itemTurn a list of records (spreadsheet rows, orders) into a list of one field's values, such as every row's Amount, so you can total, average or join them.
Group items by a fieldSort a list of records into groups that share the same value in one field, such as each owner's tasks.
Insert itemAdd an item at a specific position in a list.
Match records from two listsAdd the fields of the matching record in a second list to each record, like a spreadsheet lookup (VLOOKUP): each order gets its customer's name and plan, matched by email.
Remove an itemRemove an item from a list wherever it appears.
Remove duplicatesRemove repeated items from a list, or records that repeat a field, like two rows for one email address.
Remove item by positionRemove the item at a specific position in a list.
Reverse listReverse the order of items in a list.
Shuffle listPut the items of a list in a random order.
Sort listSort a list in ascending (first/smallest to last/largest) or descending (last/largest to first/smallest) order.
Split a list into batchesSplit a list into smaller lists of a set size, for an app that takes so many items at a time.
Take part of listTake a section of a list, such as the first five items or the last three.

Add item to end

Add an item to the end of a list.

Inputs

ListitemslistRequired
The list to add the item to.
Item to addvalueobjectRequired
The item to add. A list is added as a single item.

Outputs

The list with the item added at the end.

Example output
[
  "apples",
  "bananas",
  "cherries"
]

Check if list includes item

Check whether a list includes a specific item.

Inputs

ListitemslistRequired
The list to search.
Item to checkvalueobjectRequired
The item to look for. It must match an item exactly.

Outputs

Whether the list includes the item.

Example output
true

Combine two lists

Merge two lists into one, keeping the items of the first list followed by the items of the second. Leave the second list out to merge the lists inside one list into a single list (flatten).

Inputs

First listfirstlistRequired
The list whose items come first.
Second listsecondlist
The list whose items come after the first list's. Leave it empty when the first list holds lists to merge into one, like the results a loop gathered.

Outputs

One list: the first list's items followed by the second list's.

Example output
[
  "apples",
  "bananas",
  "cherries",
  "dates"
]

Compare two lists

Find what two lists have in common and where they differ: what is only in the first, only in the second, in both, and, for records matched by a field, which ones changed. Handy for keeping two apps in sync.

Inputs

First listfirstlistRequired
One list, like the rows of a spreadsheet.
Second listsecondlistRequired
The list to compare it with, like an app's contacts.
Match records byfieldtext
For lists of records, the field that says two records are the same one, like Email or ID. Letter case and spaces don't matter. Leave empty to compare whole items.

Outputs

Four lists: only_in_first, only_in_second, in_both (items from the first list), and changed: each matching pair holding a different value in a field both have, as first, second and the names of the fields that differ.

changedlist
Records in both with a different value in a field both have, each as first, second and fields.
in_bothlist
Items both lists have, as the first list holds them.
only_in_firstlist
Items only the first list has.
only_in_secondlist
Items only the second list has.
Example output
{
  "changed": [
    {
      "fields": [
        "plan"
      ],
      "first": {
        "email": "ben@example.com",
        "plan": "pro"
      },
      "second": {
        "email": "ben@example.com",
        "plan": "free"
      }
    }
  ],
  "in_both": [
    {
      "email": "ben@example.com",
      "plan": "pro"
    }
  ],
  "only_in_first": [
    {
      "email": "ana@example.com"
    }
  ],
  "only_in_second": []
}

Count different values

Count how many different values a list holds, or how many different values one field takes, like how many customers placed the orders. Blanks don't count.

Inputs

ListitemslistRequired
The list, or list of records, to count.
Fieldfieldtext
For a list of records, the field to count the different values of, like Customer email. Letter case and spaces don't matter.

Outputs

How many different values there are.

Example output
12

Count items

Count how many items are in a list.

Inputs

ListitemslistRequired
The list to count the items of.

Outputs

The number of items in the list.

Example output
3

Create a list

Create a list by entering its items one by one.

Inputs

ItemsitemslistRequired
The items to put in the list, in order.

Outputs

The new list, with the items in the order entered.

Example output
[
  "apples",
  "bananas",
  3
]

Edit a record

Keep only some fields of a record, remove fields, rename them, or merge in another record. Given a list of records, like spreadsheet rows, it edits each one.

Inputs

RecordrecordtextRequired
The record, or list of records, to edit.
What to doedittextRequired
How to change the record.One of: keep (Keep only some fields), remove (Remove fields), rename (Rename fields), merge (Merge in another record). Default: keep.
Fieldsfieldslist
The names of the fields, like Name and Email. Use dots to reach inside, like address.city.Only when What to do is Keep only some fields or Remove fields.
New namesrenamesobject
Each field's current name, and the name to give it.Only when What to do is Rename fields.
Record to merge inothertext
Its fields are added; where both records have a field, its value is the one kept.Only when What to do is Merge in another record.

Outputs

The edited record, or the list of edited records when a list was given.

Example output
{
  "email": "ana@example.com",
  "name": "Ana"
}

Filter list

Keep only the items in a list that match a condition, and return them as a new list. Build the condition the same way as an “If” step, referring to the current item as “item”.

Inputs

ListitemslistRequired
The list to filter. The condition reads each item in turn as item.
Keep item ifconditiontextRequired
Only items for which this is true are kept. Refer to the current item as “item” (for example, item.price is greater than 100).

Outputs

The items that meet the condition, in their original order.

Example output
[
  {
    "price": 150,
    "sku": "B2"
  },
  {
    "price": 300,
    "sku": "C3"
  }
]

Find item position

Find where an item appears in a list. Returns -1 if it is not found.

Inputs

ListitemslistRequired
The list to search.
Item to findvalueobjectRequired
The item to look for. It must match an item exactly.

Outputs

The position of the first matching item, counting from 0, or -1 if the item is not in the list.

Example output
1

Get first item

Get the first item of a list. If the list is empty, returns an empty list (shown as “Empty list”).

Inputs

ListitemslistRequired
The list to take the first item from.

Outputs

The first item in the list, of whatever type it is, or an empty list if the list has no items.

Example output
{
  "email": "ana@example.com",
  "id": 101
}

Get last item

Get the last item of a list. If the list is empty, returns an empty list (shown as “Empty list”).

Inputs

ListitemslistRequired
The list to take the last item from.

Outputs

The last item in the list, of whatever type it is, or an empty list if the list has no items.

Example output
{
  "email": "ben@example.com",
  "id": 102
}

Get one field from every item

Turn a list of records (spreadsheet rows, orders) into a list of one field's values, such as every row's Amount, so you can total, average or join them.

Inputs

List of recordsitemslistRequired
The list of records (objects), such as spreadsheet rows or an earlier step's results.
FieldfieldtextRequired
The name of the field or column to take from every record, for example Amount.

Outputs

The field's value from each record, in the same order, with null where a record has no value for it.

Example output
[
  "12.50",
  "100",
  null
]

Group items by a field

Sort a list of records into groups that share the same value in one field, such as each owner's tasks. Each group has a key (the shared value), its items, and a count. Text matches ignoring case and spaces; records with a blank value are kept together in a group with a blank key.

Inputs

List of recordsitemslistRequired
The list of records (objects) to group.
Field to group byfieldtextRequired
The name of the field or column whose value decides the group, for example Owner email.
Also work outsummarytext
A figure for each group beside its count, like the total sales for each rep. It is added to each group under its name: total, average, min or max.One of: none (Nothing more), total (The total), average (The average), min (The smallest), max (The largest). Default: none.
Of the fieldof_fieldtext
The field holding the numbers, for example Amount.Only when Also work out is The total, The average, The smallest or The largest.

Outputs

One group for each distinct value of the field, in the order the values first appear.

Example output
[
  {
    "count": 2,
    "items": [
      {
        "owner": "ana@example.com",
        "task": "Write spec"
      },
      {
        "owner": "ana@example.com",
        "task": "Ship"
      }
    ],
    "key": "ana@example.com"
  },
  {
    "count": 1,
    "items": [
      {
        "owner": "ben@example.com",
        "task": "Review PR"
      }
    ],
    "key": "ben@example.com"
  }
]

Insert item

Add an item at a specific position in a list.

Inputs

ListitemslistRequired
The list to insert the item into.
PositionindexnumberRequired
0 is the first place, and -1 puts the item last.
Item to insertvalueobjectRequired
The item to insert.

Outputs

The list with the item inserted at the position given.

Example output
[
  "apples",
  "bananas",
  "cherries"
]

Match records from two lists

Add the fields of the matching record in a second list to each record, like a spreadsheet lookup (VLOOKUP): each order gets its customer's name and plan, matched by email.

Inputs

RecordsfirstlistRequired
The records to add fields to, like orders.
Look up insecondlistRequired
The records to take the fields from, like customers.
Match byfieldtextRequired
The field the records share, like Email. Letter case and spaces don't matter.
Field in the second listother_fieldtext
When the second list names it differently, like Customer email. Leave empty when the name is the same.
Records without a matchkeeptext
Keep records that have no match as they are, or leave them out.One of: all (Keep them), matches (Leave them out). Default: all.

Outputs

The records, each with the matching record's fields added. A field both records have keeps the first record's value unless it is blank.

Example output
[
  {
    "email": "ana@example.com",
    "name": "Ana",
    "order": 1042,
    "plan": "pro"
  }
]

Remove an item

Remove an item from a list wherever it appears.

Inputs

ListitemslistRequired
The list to remove the item from.
ItemvaluetextRequired
The item to remove. Every copy of it is removed.

Outputs

The list without the item.

Example output
[
  "apples",
  "cherries"
]

Remove duplicates

Remove repeated items from a list, or records that repeat a field, like two rows for one email address. Can also remove empty items.

Inputs

ListitemslistRequired
The list to remove repeated items from.
Match records byfieldtext
For a list of records, the field that makes two records the same, like Email. The first of each is kept. Letter case and spaces don't matter. Leave empty to compare whole items.
Empty itemsremove_emptytrue/false
Keep empty items, or remove them too.Default: false.

Outputs

The list with repeated items removed, keeping the first of each.

Example output
[
  "ana@example.com",
  "ben@example.com"
]

Remove item by position

Remove the item at a specific position in a list.

Inputs

ListitemslistRequired
The list to remove the item from.
PositionindexnumberRequired
0 is the first item, and -1 is the last.

Outputs

The list without the item at the position given.

Example output
[
  "bananas",
  "cherries"
]

Reverse list

Reverse the order of items in a list.

Inputs

ListitemslistRequired
The list to reverse.

Outputs

The list's items in reverse order.

Example output
[
  3,
  2,
  1
]

Shuffle list

Put the items of a list in a random order. Returns all of the items, just reordered.

Inputs

ListitemslistRequired
The list to shuffle.

Outputs

The list's items in a random order.

Example output
[
  "dee",
  "ben",
  "ana",
  "cy"
]

Sort list

Sort a list in ascending (first/smallest to last/largest) or descending (last/largest to first/smallest) order.

Inputs

ListitemslistRequired
The list to sort. Numbers, and text that holds a number, sort by value, and dates sort by date.
Directiondirectiontext
The order to sort in.One of: ascending, descending. Default: ascending.
Sort records byfieldtext
For a list of records, the field to sort them by, like Amount or Created. Records without it go last.

Outputs

The list's items sorted in ascending or descending order.

Example output
[
  3,
  7,
  42
]

Split a list into batches

Split a list into smaller lists of a set size, for an app that takes so many items at a time. Loop over the batches to send each one.

Inputs

ListitemslistRequired
The list to split.
Items per batchsizenumberRequired
How many items each batch holds. The last may hold fewer.At least 1.

Outputs

The batches, each a list, in the original order.

Example output
[
  [
    "a",
    "b"
  ],
  [
    "c",
    "d"
  ],
  [
    "e"
  ]
]

Take part of list

Take a section of a list, such as the first five items or the last three.

Inputs

ListitemslistRequired
The list to take a section of.
Start positionstartnumberRequired
This item is included. Use a negative number to count from the end (-1 is the last item).
End positionendnumber
This item is not included. Leave blank to go through the end of the list. Use a negative number to count from the end (-1 is the last item).

Outputs

The items from the start position up to, but not including, the end position.

Example output
[
  "a",
  "b",
  "c"
]

On this page