Solved

Report Builder 3.0 Calculated Field Expression Syntax for item similar to "contains"

Posted on 2014-02-18
5
1,486 Views
Last Modified: 2014-02-20
I have a field in my database that displays a list of numbers separated by a coma.  Example "0, 1, 2" or "1, 3, 5, 6" .  I want to create a calculated field that says if the original field contains a 1, then display the corresponding text description.  The 1 could be in any location along the series.  I've tried various combinations of Iif, Left, or Like, but these keep resulting in syntax errors.  I'm looking for help to identify the proper function and related syntax.  

Any suggestions are greatly appreciated.

Thank you,
0
Comment
Question by:jaisy99
  • 2
  • 2
5 Comments
 
LVL 37

Accepted Solution

by:
ValentinoV earned 500 total points
ID: 39869689
The easiest option is to prefix and suffix the string with the delimiter and combine that with the InStr function.  In your example the delimiter is a comma followed by a space.  Here's how that goes:

=IIF(InStr(", " & Fields!YourField.Value & ", ", ", 1, "), "found", "not found")

Open in new window


Note that the search term starts and ends with the delimiter.  This is crucial because otherwise you'll find 1 while it's actually 11 (for example).
0
 
LVL 1

Author Comment

by:jaisy99
ID: 39873472
Thank you for pointing me in the right direction with Instr.  I'm new to report building and did not think to go to Instr first.  I ended up going with the following syntax =IIF(InStr(Fields!CF_Str.Value,"1")>0,"Found", " ")   , but the suggested syntax was helpful as well.
0
 
LVL 1

Author Closing Comment

by:jaisy99
ID: 39873484
What I needed.  Thanks!
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 39873503
I ended up going with the following syntax =IIF(InStr(Fields!CF_Str.Value,"1")>0,"Found", " ")   , but the suggested syntax was helpful as well.

Well, as long as your numbers don't go higher than 9 it should work fine.  Otherwise you'll run into the issue mentioned in my first post.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, I am very much excited today since I'm going to share something very exciting Tool used for Analytical Reporting and that's nothing but MICROSTRATEGY. Actually there are lot of other tools available in the market for Reporting Such as Co…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now