What is concat?
Concat (or concatenate) is a function that combines multiple strings into a single string. The word comes from the Latin root con- for “together”, and caten- for “chain”. For example, you might want to concatenate a city (Vienna) with a country (Austria) to get a single location string like “Vienna, Austria”.
concat expression is translated into a SQL
CONCAT function when running against your database, like this:
SELECT CONCAT(City, ", ", Country) AS "Location"
In Metabase and other BI tools, you can assume that
concat only works with the text data type (often called a string). If you want to use
concat with other data types, like numbers or dates, you’ll have to convert them to text first.
If you prefer to write SQL, note that the functions
MERGE might sound like they work similarly to
CONCAT, but they are used to combine rows and columns from different tables, rather than text strings from different columns.
- Custom expressions in the notebook editor
- Custom expression documentation
- Best practices for writing SQL queries
Did this article help you?
Thanks for your feedback!