How to replace multiple strings in the same Expression/field using replaceString function

Hi Team,

I have this requirement to replace multiple strings in an expression which is having two different substrings.

For the Example below:

Category field has two results either A or B and I want to replace ‘A’ with ‘XML’ and ‘B’ with ‘TEXT’.

I have used below command with replaceString and it worked for ‘A’.

fieldsAdd replaceString(Category, “A”, “XML”)

How do I replace the another string B in the same Category field(without adding new fieldsAdd command.)

Thanks,

if “Category field has two results either A or B” why do you need replaceString, not just if?

If my understanding of assumption is correct, this could look like this:

data record(Category="A"),
record(Category="B")
| fieldsAdd Category = coalesce(
  if(Category=="A","XML"),
  if(Category=="B","TEXT"))

Can you try this :
| fieldsAdd CategoryReplaced = replaceString(replaceString(Category, “A”, “XML”), “B”, “TEXT”)
please check the simple Example :

This works too. Thank you for the response.

I was looking to get my hands on ‘string functions’ by dynatrace also more results might be added in the future.