Grouping records is a common need when analyzing or reporting data. Organizing records into logical groups often makes it easier to summarize and present data. Logical groups refer to data organized by categories such as; Date, Employee types, Book authors, Music genres, and many others.

Grouped data is formed by aggregating individual observations of a variable into groups. The frequency distribution of these groups serves as a convenient means of summarizing or analyzing the data.

In Synatic, there is a Group step to help with this task. You can group values in multiple records into a single array by grouping the records according to the values in one or more unique key fields.

This reference article will discuss the Group step to logically organize specific records in a dataset.


Adding the Group Step

In Synatic, the Group step is located in the Mapper drawer of the Steps palette. To use the Group step in your flow, you would simply select and drag it onto the desired location in the flow, and then you can configure the step.


Configuring the Group Step

The Group step only requires you to define one or more key ID Fields to identify each record uniquely.

The Group step will categorize records based on the defined ID Fields with the same value in the dataset.

  • ID Fields - Enter the key ID field you want to use to order the data

Field Entry Controls
These controls are indicated by icons and can assist you with adding, editing, and removing fields in the form. The icons are expanded below:

  • 🖊 - Click to edit the current field.

  • ⊝ - Click to remove the current field.

  • ✔ - Click to accept a new field.

  • ⨂ - Click to remove the field being entered.

  • ⨁ - Click to add a new field.

  • </> - Click to open a code block where you can manually enter and manage Group fields using the JSON format.

  • ▦ - Click to return to the field entry form.


Sorting the records

To use the Group step functionality, Synatic must first Sort the records. The Group step is designed to keep memory-use efficient, so we'll add the Sort step to order the data on a defined key field.

The Group step is designed to keep memory-use efficient, so use the Sort step to order the data on the key field before the Group step processes it. The data must be in sorted order for the Group step to group the data successfully.

  • Field - Enter the field you want to use to order the data.

  • Order - Click on the list selection arrow to sort the data in Ascending or Descending order.


Example

In a typical example, the Group step would exist in a Synatic flow similar to the one shown below.

Synatic - Insert Group step into flow

For the example below, let's assume our input record looks like the structure below. It consists of a list of ToDo records each containing a completion status.

Synatic - Display JSON debug data for the Group step

For clarity, each record retrieved has the following structure:

{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": "false"
}

We want to group the records on the Todo list status, so we use the Completed field in the Group step configuration.

Synatic - Edit Group Step

Records grouped on the same completed status

We can see the two data arrays created by the Group step, has one group of False status and the other group of the True status. You can get an idea of the data and its format. The output looks like this:

Synatic - Display JSON debug data for the Calculator step

The small sample shown below of the expanded list of array items, shows only the False group of records and looks as follows:

{
"id": {
"completed": false
},
"items": [
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
},
{
"userId": 1,
"id": 2,
"title": "quis ut nam facilis et officia qui",
"completed": false
},
{
"userId": 1,
"id": 3,
"title": "fugiat veniam minus",
"completed": false
}
]
}

If you compare the input and output data structures, you can see how the Group step functions. You can now add functionality in the flow to process the records further.


Options

None.


Advanced Mode Options

None.


Limitations and known issues

None.


See Also

Read more about the Field Mapper step.

Read more about the Super Mapper step.


Useful Tutorials

See the Group tutorial.

Revisit the Getting Started page for a refresher.

Read more about Steps here.

Did this answer your question?