# Data Mapping cfxdm - dm:mergecolumns

**dm:mergecolumns:** This cfxdm function allows the user to select multiple columns using include or exclude columns options using a regular expression format and merge them into a single target column.

**dm:mergecolumns** synta&#x78;**:**&#x20;

* **include (**&#x4D;andator&#x79;**):** Specify a column or columns in regular expression format to include matched columns.
* **exclude (**&#x4F;ptiona&#x6C;**):** Specify a column or columns in regular expression format to exclude matched columns.
* **to** (Mandatory): Target column for merged data from selected one or more columns.

{% hint style="info" %}
**Note:** After merging multiple columns into a single column, it will remove source columns from the final output.
{% endhint %}

### Example 1:

Step 1: Create an empty **dm\_mergecolumns\_example\_1** using AIOps studio as shown in the below screenshot.

![Empty pipeline](/files/-MfdQeH9N-PNbmLEB-2R)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.\
\
\&#xNAN;*`##### This pipeline creates a set of records/dateset details coming from a netflow`*  \
*`##### environment.`* \
\
*`##### This dataset includes flow.client_addr, flow.server_addr, flow.service_port as`* \
*`##### source columns. This pipeline uses dm mergecolumns to merge the source columns`*\
*`##### to a single target column`*\
\
*`@dm:empty`* \
*`--> @dm:addrow flow.client_addr = '10.95.133.42' & flow.server_addr = '10.95.133.40' & flow.service_port = '9092'`* \
*`--> @dm:addrow flow.client_addr = '10.95.122.170' & flow.server_addr = '10.95.122.169' & flow.service_port = '9092'`*\
&#x20;*`--> @dm:addrow flow.client_addr = '10.95.122.170' & flow.server_addr = '10.95.122.169' & flow.service_port = '9092'`* \
*`--> @dm:addrow flow.client_addr = '10.95.122.170' & flow.server_addr = '10.95.122.169' & flow.service_port = '9092'`* \
*`--> @dm:addrow flow.client_addr = '10.95.122.205' & flow.server_addr = '10.95.122.212' & flow.service_port = '9300'`* \
*`--> @dm:addrow flow.client_addr = '10.95.117.35' & flow.server_addr = '10.95.117/37' & flow.service_port = '686'`* \
*`--> @dm:addrow flow.client_addr = '10.95.122.105' & flow.server_addr = '10.95.122.212' & flow.service_port = '443'`* \
*`--> @dm:addrow flow.client_addr = '10.95.122.105' & flow.server_addr = '10.95.122.212' & flow.service_port = '9300'`* \
*`--> @dm:addrow flow.client_addr = '10.95.122.121' & flow.server_addr = '10.95.122.212' & flow.service_port = '9092'`*\
&#x20;*`--> @dm:addrow flow.client_addr = '10.95.122.109' & flow.server_addr = '10.95.122.212' & flow.service_port = '8443'`*\
\
*`--> @dm:mergecolumns include = 'flow.client_addr|flow.server_addr|flow.service_port' & to = 'flow.unique_id'`*

![Pipeline code added ](/files/-MfdTUON3zg-U4hKagDY)

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![Pipeline code is verified using 'Verify' button as shown above](/files/-MfdUAf7fgtuti5sJMnd)

Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below).

![Screenshot -1 ](/files/-MfdUhzIbiduUZxTVPCx)

![Screenshot - 2 (successful execution of pipeline)](/files/-MfdVWY2kHRPoBeGvmKv)

Step 5: RDA uses the dm mergecolumns function to merge the specified columns into target column and prints the resultant output as shown in the following screenshot.

![Three columns are merged into single target column as shown in the above screenshot.](/files/-MfdWQVKwuw-KnR_4erd)

dm: merge functionality will be very useful when uniqueness is needed from within the dataset by combining couple of columns into one column as a key.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudfabrix.io/rda/rda-userguide/rda-aiops-studio/examples-jupyter/data-mapping-cfxdm-dm-mergecolumns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
