Solved

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

Posted on 2014-02-18
1,559 Views
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
Question by:jaisy99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2
• 2

LVL 37

Accepted Solution

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")
``````

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

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

ID: 39873484
What I needed.  Thanks!
0

LVL 37

Expert Comment

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

Question has a verified solution.

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

It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month3 days, 4 hours left to enroll