Is it possible to use one replace function to replace multiple strings in one field?

青春壹個敷衍的年華 提交于 2019-12-01 17:33:36

You have to nest the function's

For example to replace 1 with a and 0 with b you can write the expression below

=Replace(Replace(Fields!field1.Value,"1","a"),"0","b")

This can be a bit tricky (at first) when you have a string that has part of it repeated in the string after it that you also want to replace. To give you an example: If you use the nested function from niktrs to replace "Test" with "Test A" and "Test B" with "Test C" it returns "Test A" and "Test A B". In this example you need to adjust the expression to:

=Replace(Replace(Fields!Field1.Value,"Test","Test A"),"Test A B","Test C")

With 2 or more of these type of strings you need to work your way (down the tablix) to the last value that needs replacing, which could leave you with a relatively lengthy expression, unfortunately. It's probably better to alter the query for the dataset you're working with.

It look nice if you do it with

=Switch(
    Fields!Status.Value = "20", "Entered",
    Fields!Status.Value = "30", "Returned",
    Fields!Status.Value = "200", "Cancelled",
    Fields!Status.Value = "220", "Complete",
    Fields!Status.Value = "300", "Deleted"
)

Got it from another stackoverflow anser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!