13 May 2025 11:48 AM
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,
Solved! Go to Solution.
13 May 2025 09:28 PM
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"))
14 May 2025 09:46 AM
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.
13 May 2025 10:08 PM
Can you try this :
| fieldsAdd CategoryReplaced = replaceString(replaceString(Category, "A", "XML"), "B", "TEXT")
please check the simple Example :