0

There is a column whose values of form CodeXX has been misspelled as Code-XX in some of the records/rows. I want to merge all Code-XX to CodeXX while doing aggregation operation in Tableau. How can I merge the misspelled data value with the correctly spelled one within a column?

Saurav Sahu
  • 13,038
  • 6
  • 64
  • 79

3 Answers3

0

A calculate field should work for you, like so:

IF [column_name] = 'Code-XX'
THEN 'CodeXX'
ELSE [column_name]
END
  • In my ques, `XX` represents any two digit number. Say for example, `Code-10` or `Code-99` which should be mapped against `Code10` and `Code99` respectively. Hard coding won't work. – Saurav Sahu Dec 02 '19 at 13:40
  • @SauravSahu you should have mentioned it in the question. –  Dec 03 '19 at 05:16
0

I found a simple solution:

Right Click on the Field > Create > Calculated Field > Give name to new field (say Code2)

Add this expression:

REGEXP_REPLACE([code]  , '-' ,'')

Done.

Saurav Sahu
  • 13,038
  • 6
  • 64
  • 79
0

The following calculation will work in your scenario.

REGEXP_REPLACE([Column],'\-','')

Use '\' to escape hyphen in your column.

Original column and cleaned column.

Hope that helps!