Table of Contents

Column Mapping

Block Group: Table Operations
Icon:Column Mapping block icon

The Column Mapping block returns a new table that can include specified columns from the input table and can include new columns that contain calculated values.

For information on using dataflow blocks, see Dataflow.

For answers to some common questions about working with tables, see Tables.


Input/Output Properties

The following properties of the Column Mapping block can take input and give output.

input receives the input table.

retainColumns specifies whether to include the input table's columns in the output table.

name n specifies the new column name.

from n specifies the data that will appear in the new column, using JavaScript notation. For example:


Output Properties

The following properties of the Column Mapping block can give output but cannot take input.

output returns the output table with new columns.

print displays error messages and other notifications for debugging your dataflow.


Storing Temporary Values

You can use $.<variable> in Column Mapping and Filter to store any temporary variable between rows.

The following example returns the value of v1 from the previous row.

=function(){var prev = $.v1cache; $.v1cache = v1; return prev}()

The following example returns the difference between this row's v1 and the previous row's v1. The example converts both values to millisecondsSinceEpoch, then divides the difference by 60,000 to get minutes.

=function(){var diff = (dateParse(v1) - $.a)/1000/60; $.a = dateParse(v1); return diff}()

Parsing a JSON Object

The following image shows an example. In this example, a column of the input table contains JSON. The output table contains the input JSON and also the value of the bcd item in the JSON for each row. See also: Scripting and Syntax.


Examples

The following images show examples of the Column Mapping block. In the first example, the new column displays a reformatted date string. In the second example, inches are converted to centimeters.

Column Mapping block example

Column Mapping block example


Use Cases

These threads in the DGLogik Community Forum show some use cases for the block: