SSRS Contains or Like Expression

后端 未结 1 1375
暗喜
暗喜 2021-02-08 06:33

I\'m trying to create a calculated expression from a field in my dataset. I need to find everything that contain the word Exchange Traded from one field and in my new field hav

相关标签:
1条回答
  • 2021-02-08 06:51

    In String is your friend. You pass 2 arguments to the function InStr(), the first is the text to search and the second is the text you're searching for, it returns an Integer which represents the starting position of the text you're looking for in the text you told it to search. If it can't find the text, it returns 0, which you can use as false (or simply use >0 to represent true). So...

    =iif(InStr(Fields!DESC2.Value, "Exchange Traded") > 0, "ETF_13F", Nothing)

    So that's looking for the string "Exchange Traded" in the field "DESC2". If it finds "Exchange Traded" then it returns a value that is more than 0, so all we do is say "If this value is more than 0, show ETF_13F, otherwise show nothing"

    Hope that helps

    EDIT:

    A few people have upvoted this, so as it's getting some visibility I'm going to update the answer to say there's a better way that someone clued me in to. You can simply use .Contains() on String fields to perform the same inspection:

    =iif(Fields!DESC2.Value.Contains("Exchange Traded"), "ETF_13F", Nothing)
    
    0 讨论(0)
提交回复
热议问题