How To: Find the Size of an Array Using the Size Operator

Prev Next

The Size operator counts the number of values in a string, but it can also count the number of elements in an array. In this how-to guide, you’ll learn how to use a Size operator and count the number of rows in a data table.  

You’ll find the Size operator under the Array operators group to the left of the Data Workflow canvas.

Finding the Size of an Array

In this example, you’ll use a Size operator and count the number of rows in a data table.  

These instructions assume you have a new module open, saved, and with a title.

Configure the Data Table Component

Begin by adding a Data Table component with a list of dogs’ names and ages.

  1. In the Module Builder, drag and drop a Data Table component onto your canvas.

  2. In the Property ID field, enter dtDogs.

  3. In the data table, enter the following:

    #

    A

    B

    1

    name

    age

    2

    Ivy

    7

    3

    Lucy

    10

    4

    Wally

    1

    5

    Nacho

    5

    6

    Thor

    5

    7

    Holly

    13

  4. Click Save Component.

Configure the Text Field Component

Next, configure a Text Field component to store the output from your Data Workflow. This Text Field component displays the number of rows in your array. To prevent end-users from making changes to the field, you’ll enable the Disable User Input setting in the component.

  1. Drag and drop a Text Field component onto your canvas, placing it below your dtDogs Data Table component.

  2. In the Property ID field, enter numberOfRows.

  3. In the Label Text field, enter Number of Data Table Rows.

  4. From the Input Behavior drop-down, select Disable User Input.

  5. Click Save Component.

Configure the Data Workflow Component

Lastly, configure your Data Workflow component, starting with an Input operator to bring data from your table into the Data Workflow. Then, add a Size operator to locate the number of rows the table stores. Then, output the result to your Text Field component.

  1. Drag and drop a Data Workflow component onto your canvas, placing it below your numberOfRows Text Field component.

  2. In the Property ID and Canvas Label Text fields, enter dwfSize.

  3. From the Trigger Type drop-down, select Watch.

Configure the Input Operator

  1. Drag and drop an Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    dtDogs

    Required

    Yes

    Source

    Default

Configure the Size Operator

This operator counts the number of rows in your data table.

  1. Drag and drop a Size operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Size

    Label

    Size of Data Table

  3. Connect the output port (right) of the dtDogs Input operator to the input port (left) of the Size of Data Table Size operator.

Configure the Output Operator

This operator sends the Size operator's value to your Text Field component.

  1. Drag and drop an Output operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Output

    Component

    numberOfRows

    Action

    value

  3. Connect the output port (right) of the Size of Data Table Size operator to the input port (left) of the numberOfRows Output operator.

  4. Click Save Component.

  5. Save your module.

Here's how your module looks in the Module Builder:

Preview your module in Express View, and you’ll see your Text Field component display the number of rows in your table. Return to your Data Table component in the Module Builder and adjust the number of rows to see new results in Express View.

The Size operator counts the number of values in a string, but it can also count the number of elements in an array. In this how-to guide, you’ll learn how to use a Size operator and count the number of rows in a data table.  

You’ll find the Size operator under the Array operators group to the left of the Data Workflow canvas.

Finding the Size of an Array

In this example, you’ll use a Size operator and count the number of rows in a data table.  

These instructions assume you have a new module open, saved, and with a title.

Configure the Data Table Component

Begin by adding a Data Table component with a list of dogs’ names and ages.

  1. In the Module Builder, drag and drop a Data Table component onto your canvas.

  2. In the Label and Property Name fields, enter dtDogs.

  3. In the data table, enter the following:

    #

    A

    B

    1

    name

    age

    2

    Ivy

    7

    3

    Lucy

    10

    4

    Wally

    1

    5

    Nacho

    5

    6

    Thor

    5

    7

    Holly

    13

  4. Click Save.

Configure the Text Field Component

Next, configure a Text Field component to store the output from your Data Workflow. This Text Field component displays the number of rows in your array. To prevent end-users from making changes to the field, you’ll enable the Disable User Input setting in the component.

  1. Drag and drop a Text Field component onto your canvas, placing it below your dtDogs Data Table component.

  2. In the Property ID field, enter numberOfRows.

  3. In the Label Text field, enter Number of Data Table Rows.

  4. Set Disable User Input to (ON).

  5. Click Save & Close.

Configure the Data Workflow Component

Lastly, configure your Data Workflow component, starting with an Input operator to bring data from your table into the Data Workflow. Then, add a Size operator to locate the number of rows the table stores. Then, output the result to your Text Field component.

  1. Drag and drop a Data Workflow component onto your canvas, placing it below your numberOfRows Text Field component.

  2. In the Canvas Label Text and Property Name fields, enter dwfSize.

  3. From the Trigger Type drop-down, select Watch.

Configure the Input Operator

  1. Drag and drop an Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    dtDogs

    Required

    Yes

    Source

    Default

Configure the Size Operator

This operator counts the number of rows in your data table.

  1. Drag and drop a Size operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Size

    Label

    Size of Data Table

  3. Connect the output port (right) of the dtDogs Input operator to the input port (left) of the Size of Data Table Size operator.

Configure the Output Operator

This operator sends the Size operator's value to your Text Field component.

  1. Drag and drop an Output operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Output

    Component

    characters

    Action

    value

  3. Connect the output port (right) of the Size of Data Table Size operator to the input port (left) of the numberOfRows Output operator.

  4. Click Save.

  5. Save your module.

Here's how your module looks in the Module Builder:

Preview your module in Express View, and you’ll see your Text Field component display the number of rows in your table. Return to your Data Table component in the Module Builder and adjust the number of rows to see new results in Express View.