我一直在寻找一段时间来回答我认为可能非常简单的问题,并且我认为我已经在stackoverflow上找到了它:
SSRS Reporting Services - Bold Word in String
但遗憾的是它不起作用。我正在尝试拆分出现某个单词的字符串(在本例中为“Office”)而不是参数,并将所有内容放在该单词的左侧。
E.g。如果字符串表示“London Main Office South 123”或“Birmingham Main Office North 123”,我只想要“London Main”或“Birmingham Main”,如果“Office”没有出现,则为空白。
这是我尝试过的,但我在输出上得到#Error:
=IIF(Instr(Fields!myString.Value, "Office"), Left( Fields!myString.Value , Instr( Fields!myString.Value , "Office") - 1 ),"")
答案 0 :(得分:3)
试试这个表达式:
=IIF(Instr(Fields!myString.Value, "Office"),
split(Fields!myString.Value,"Office").GetValue(0)
,Fields!myString.Value)
它只是意味着
=IIF( <condition>myString Contains Office,
<true> yes so split it and grab the first part,
<false> no it doesn't leave the string as it is
)
基本上,您需要检查Fields!myString.Value
是否包含keyWord“Office”。如果是,则需要拆分字符串并选择第一部分,否则,您需要保留原始字符串。 (你没有这样做)