# compare-columns

## Description

<mark style="color:purple;">`compare-columns`</mark> *adaptor checks whether values in two or more columns in a given datatable are the same or different.*

When all values in the specified `columns` are the same, the row is added to the `same` output datatable, otherwise the row is added to the `different` output datatable.

## Inputs

**`data`**\
Type: `datatable`\
Required: Yes\
The datatable containing columns to compare.

**`columns`**\
Type: `list`\
Required: Yes\
A list of columns to be compared.

**`case sensitive`**\
Type: `boolean`\
Required: No\
Whether lowercase and uppercase letters should be treated as equivalent. If unspecified, defaults to `False` (lowercase and uppercase letters are treated as equivalent).

## Outputs

**`same`**\
Type: `datatable`\
A datatable containing rows which have the same values in selected columns.

**`different`**\
Type: `datatable`\
A datatable containing rows which have different values in selected columns.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`data`:

| Sample ID | A | B | C |
| --------- | - | - | - |
| Sample A  | R | R | R |
| Sample B  | S | R | S |
| Sample C  | R | S | I |
| Sample D  | I | R | R |
| Sample E  | R | r | R |
| Sample F  | r | r | r |

`columns`:

* A
* B
* C

`case sensitive`: *null (empty)*

#### Outputs:

`same`:

| Sample ID | A | B | C |
| --------- | - | - | - |
| Sample A  | R | R | R |
| Sample E  | R | r | R |
| Sample F  | r | r | r |

`different`:

| Sample ID | A | B | C |
| --------- | - | - | - |
| Sample B  | S | R | S |
| Sample C  | R | S | I |
| Sample D  | I | R | R |

-> Compared the columns `A`, `B` and `C` and return the rows with same and different values.

### Example 2: Case sensitive comparison.

#### Inputs:

`data`:

| Sample ID | A | B | C |
| --------- | - | - | - |
| Sample A  | R | R | R |
| Sample B  | S | R | S |
| Sample C  | R | S | I |
| Sample D  | I | R | R |
| Sample E  | R | r | R |
| Sample F  | r | r | r |

`columns`:

* A
* B
* C

`case sensitive`: True

#### Outputs:

`same`:

| Sample ID | A | B | C |
| --------- | - | - | - |
| Sample A  | R | R | R |
| Sample F  | r | r | r |

`different`:

| Sample ID | A | B | C |
| --------- | - | - | - |
| Sample B  | S | R | S |
| Sample C  | R | S | I |
| Sample E  | R | r | R |
| Sample D  | I | R | R |

-> Compared the columns `A`, `B` and `C` and return the rows with same and different case sensitive values.


---

# 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://cgps.gitbook.io/data-flo/reference-guide/compare-columns.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.
