Dataset - Move column

Declaration

<AMDATASET ACTIVITY="move_column" DATASET="text" COLUMNBY="text (options)" COLUMN="text/number" MOVETO="text (options)" DESTCOLUMN="text/number" />

Related Topics   

Description

Moves a column anywhere in a dataset.

Practical usage

Used to move a column anywhere in a dataset.

Parameters

General

Property Type Required Default Markup Description
Dataset name Text Yes (Empty) DATASET="Customers" Specifies the dataset to move the column in.
Select by Text (options) Yes Column name
  • COLUMNBY="name"
  • COLUMNBY="index"
Specifies how to identify the column to move. The options are:
  • Column name (default) - Identifies the column to move by column name.
  • Column index - Identifies the column to move by column index number.
Column name Text Yes, if Select by is set to Column name (Empty) COLUMN="State" The name of the column to move. This parameter is required if Select by is set to Column name.
Column index Number Yes, if Select by is set to Column index (Empty) COLUMN="5" The index number of the column to move. This parameter is required if Select by is set to Column index.
Move to Text (options) Yes End MOVETO="index"

MOVETO="end"

MOVETO="before"

MOVETO="after"
Specifies where to move the column to. The options are:
  • Column index - Moves the column to the specified column index number.
  • End (default) - Moves the column to the end of the dataset.
  • Before specified column name - Moves the column to appear before the specified column name.
  • After specified column name - Moves the column to appear after the specified column name.
Column index Number Yes, if Move to is set to Column index (Empty) DESTCOLUMN="7" The column index number to move the column to. This parameter is required if Move to is set to Column index.
Column name Text Yes, if Move to is set to Before specified column name or After specified column name (Empty) DESTCOLUMN="Zip" The name of the column to move the column before or after. This parameter is required if Move to is set to Column name.

Description

Error Causes

On Error

Examples

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Example 1

This task uses the Create and Insert row Dataset activities to create a dataset with three columns and three rows and then moves the heading1 column to the end of the dataset.

Copy
<AMDATASET RESULTDATASET="myDataset" COLUMNS="heading1;heading2;heading3" DELIMITER="semi_colon" DESCRIPTION="This is user input description showing in variables panel of Task Builder" />
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row1" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row2" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row3" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="move_column" DATASET="myDataset" COLUMNBY="name" COLUMN="heading1" MOVETO="end" />

Example 2

This task uses the Create and Insert row Dataset activities to create a dataset with three columns and three rows and then moves the first column to appear after the heading3 column.

Copy
<AMDATASET RESULTDATASET="myDataset" COLUMNS="heading1;heading2;heading3" DELIMITER="semi_colon" DESCRIPTION="This is user input description showing in variables panel of Task Builder" />
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row1" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row2" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row3" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="move_column" DATASET="myDataset" COLUMNBY="index" COLUMN="1" MOVETO="after" DESTCOLUMN="heading3" />