Replace in custom column

Hello, even with the text() function, I get the error message “Types are incompatible” when using replace()? How can I better formulate the query? Regards, Martin

replace(
  text([ProjektDaten - ProjektNummer → Projektkurzname]),
  text([ProjektNummer]),
  ""
)

The replace() custom column function only accepts string literals (“quoted strings like this”) for the second and third arguments. You can’t use a column reference in those arguments, even if you cast the value.

At least on PostgreSQL, the database level replace() function does accept a column name/value as an argument, so you could write your query as a native query.

you can't this as part of your query?

OP is using the notebook editor, not the native query editor.

It's definitely possible with native SQL. I use the visual SQL builder to increase acceptance among my colleagues who are not developers. That's one of the advantages of Metabase.

Models and database views are your friends for preparing data for presentation and getting around Metabase limitations. Can’t do it in the notebook editor? Make a Model that uses a SQL query to fix it instead. Your users can use the Model as a base for their own notebook-based queries.

Yes, that's a good idea. I haven't looked into models yet.