2

I've been looking for a while now for an answer to what I think is probably quite an easy one, and thought I'd found it on stackoverflow here:

SSRS Reporting Services - Bold Word in String

But sadly it's not working. I'm trying to split a string where a certain word appears (in this case "Office") rather than a Parameter, and take everything to the left of that word.

E.g. where the string states 'London Main Office South 123' or 'Birmingham Main Office North 123', I just want 'London Main' or 'Birmingham Main', and if 'Office' does not appear then blank.

Here's what I've tried, but I'm getting #Error on the output:

=IIF(Instr(Fields!myString.Value, "Office"), Left( Fields!myString.Value , Instr( Fields!myString.Value , "Office") - 1 ),"")
4

1 回答 1

3

try this expression:

=IIF(Instr(Fields!myString.Value, "Office"),     
        split(Fields!myString.Value,"Office").GetValue(0)
       ,Fields!myString.Value)

it simply means

=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
 )

basically, you need to check whether Fields!myString.Value contains keyWord "Office". If it does, you need to split your string and select the first part, otherwise, you need to leave the original string as it is. (which you were not doing)

于 2013-04-09T10:01:03.090 回答