Skip to content
Snippets Groups Projects
Unverified Commit eddda24f authored by Natalie's avatar Natalie Committed by GitHub
Browse files

docs - concat (#25639)

parent d4472ad5
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,7 @@ For an introduction to expressions, check out [Writing expressions in the notebo
- [case](./expressions/case.md)
- [ceil](#ceil)
- [coalesce](./expressions/coalesce.md)
- [concat](#concat)
- [concat](./expressions/concat.md)
- [contains](#contains)
- [endswith](#endswith)
- [exp](#exp)
......@@ -240,7 +240,7 @@ Syntax: `coalesce(value1, value2, …)`
Example: `coalesce([Comments], [Notes], "No comments")`. If both the `Comments` and `Notes` columns are null for that row, the expression will return the string "No comments".
### concat
### [concat](./expressions/concat.md)
Combine two or more strings together.
......
......@@ -114,7 +114,7 @@ case(condition1, "string", condition2, TRUE, condition3, 1)
case(condition1, "string", condition2, "TRUE", condition3, "1")
```
## Converting a function into a `case` expression
## Related functions
This section covers functions and formulas that can be used interchangeably with the Metabase `case` expression, with notes on how to choose the best option for your use case.
......
......@@ -74,7 +74,7 @@ Use the same data types within a single `coalesce` function. If you want to coal
If you want to use `coalesce` with JSON or JSONB data types, you'll need to flatten the JSON objects first. For more information, look up the JSON functions that are available in your SQL dialect. You can find some [common SQL reference guides here][sql-reference-guide].
## Converting a function into a `coalesce` expression
## Related functions
This section covers functions and formulas that can be used interchangeably with the Metabase `coalesce` expression, with notes on how to choose the best option for your use case.
......
---
title: Concat
---
# Concat
`concat` joins text data (strings) from two or more columns.
| Syntax | Example |
|-------------------------------|------------------------------------------|
| `concat(value1, value2, ...)` | `concat("Vienna, ", "Austria")`|
| Combines two or more strings. | "Vienna, Austria" |
## Combining text from different columns
| City | Country | Location |
|----------|---------|------------------|
| Vienna | Austria | Vienna, Austria |
| Paris | France | Paris, France |
| Kalamata | Greece | Kalamata, Greece |
where **Location** is a custom column with the expression:
```
CONCAT([City], ", ", [Country])
```
## Accepted data types
| [Data type](https://www.metabase.com/learn/databases/data-types-overview#examples-of-data-types) | Works with `concat` |
| ----------------------- | -------------------- |
| String | ✅ |
| Number | ❌ |
| Timestamp | ❌ |
| Boolean | ❌ |
| JSON | ❌ |
## Related functions
This section covers functions and formulas that work the same way as the Metabase `concat` expression, with notes on how to choose the best option for your use case.
- [SQL](#sql)
- [Spreadsheets](#spreadsheets)
- [Python](#python)
### SQL
In most cases (unless you're using a NoSQL database), questions created from the [notebook editor](https://www.metabase.com/glossary/notebook_editor) are converted into SQL queries that run against your database or data warehouse.
If our [sample data](#combining-text-from-different-columns) is stored in a relational database:
```sql
SELECT
CONCAT(City, ", ", Country) AS "Location"
FROM
richard_linklater_films;
```
is equivalent to the Metabase `concat` expression:
```
concat([City], ", ", [Country])
```
### Spreadsheets
If our [sample data](#combining-text-from-different-columns) is in a spreadsheet where "City" is in column A, and "Country" in column B, we can create a third column "Location" like this,
```
=CONCATENATE(A2, ", ", B2)
```
which is equivalent to the Metabase `concat` expression:
```
concat([City], ", ", [Country])
```
### Python
Assuming the [sample data](#combining-text-from-different-columns) is in a dataframe column called df,
```
df["Location"] = df["City"] + ", " + df["Country"]
```
is the same as the Metabase `concat` expression:
```
concat([City], ", ", [Country])
```
## Further reading
- [Custom expressions documentation](../expressions.md)
- [Custom expressions tutorial](https://www.metabase.com/learn/questions/)
\ No newline at end of file
......@@ -58,7 +58,7 @@ The first row's blank cell doesn't have an empty string, but because it's blank,
- `isempty` only accepts one value at a time. If you need to deal with empty strings from multiple columns, you'll need to use multiple `isempty` expressions with the [case expression](./case.md).
- If `isempty` doesn't seem to do anything to your blank cells, you might have `null` values. Try the [`isnull` expression](./isnull.md) instead.
## Converting a function into an `isempty` expression
## Related functions
This section covers functions and formulas that can be used interchangeably with the Metabase `isempty` expression, with notes on how to choose the best option for your use case.
......
......@@ -56,7 +56,7 @@ The second row's blank cell doesn't have a `null`, but we're not sure what's in
- `isnull` only accepts one value at a time. If you need to deal with blank cells across multiple columns, see the [coalesce expression](./coalesce.md).
- If `isnull` doesn't seem to do anything to your blank cells, you might have empty strings. Try the [`isempty` expression](./isempty.md) instead.
## Converting a function into an `isnull` expression
## Related functions
This section covers functions and formulas that can be used interchangeably with the Metabase `isnull` expression, with notes on how to choose the best option for your use case.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment