# Aggregate String

Aggregate strings across rows by concatenating them together, and grouping by other columns.

Uses a text separator to aggregate the string values together, and returns a single column where the rows are the aggregated strings.

## Parameters

| Name         | Type            | Description                                                                                                                  | Is Optional |
| ------------ | --------------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- |
| agg\_columns | column\_list    | Columns with string values to aggregate                                                                                      |             |
| sep          | value           | Text separator to use when aggregating the strings, i.e. ', '.                                                               |             |
| group\_by    | column\_list    | Columns to group by when applying the aggregation.                                                                           |             |
| distinct     | boolean         | If you want to collapse multiple rows of the same string value into a single distinct value, use TRUE. Otherwise, use FALSE. |             |
| order        | sort\_direction | ASC or DESC, to set the alphabetical order of the agg\_column when aggregating it                                            |             |

## Example

```python
product = rasgo.get.dataset(75)

ds2 = product.aggregate_string(group_by=['PRODUCTLINE'],
                agg_columns=['PRODUCTKEY', 'ENGLISHPRODUCTNAME'],
                sep=', ',
                distinct='FALSE',
                order='ASC')
ds2.preview()
```

## Source Code

{% embed url="<https://github.com/rasgointelligence/RasgoTransforms/blob/main/rasgotransforms/rasgotransforms/transforms/aggregate_string/aggregate_string.sql>" %}


---

# 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.rasgoml.com/rasgo-docs/rasgo-0.1/all-transforms/aggregate_string.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.
