I am trying to extract only the numbers from a string; for example:
+36,145
Expected result:
36145
For Chart-level fields, adding the CAST
function and setting the field AS NUMBER
ensures that it can be aggregated as required, when set as a metric (REGEXP_REPLACE
defaults to a TEXT field):
CAST(REGEXP_REPLACE(X, "(\\+|,)", "") AS NUMBER )
Google Data Studio Report and GIF to elaborate: