Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

need to format tablix cell based on data

Posted on 2011-02-15
5
Medium Priority
?
1,299 Views
Last Modified: 2012-05-11
SSRS Newbie here.
Using SQL 2008 R2

I need to examine a report tablix cell and, if it begins with a certain text, say "xyz:" I need to change the background color of that cell and peel off the letters "xyz:".

So if the data was "xyz:Michigan" the report would show the word "Michigan" with a green background.

I know I can go into the textbox proprties fill property and do something like:
=Iif(ReportItems!State like "xyz:", "Green", "No Color")

So, for color changing the cell background, the problem is of course that SSRS doesn't like the "like" operator. What can I use in its place?

I'm not even sure where to begin on removing the "xyz:". Any ideas from our SSRS experts?

As a follow-up, does anyone have a good link to SSRS Expression examples? I've tried the one in MSDN (http://msdn.microsoft.com/en-us/library/ms157328.aspx) and while it has some good examples, none that really help me here.

Thanks in advance.
0
Comment
Question by:kalittaair
[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
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:planocz
ID: 34903055
Ok here you go...
Place this code in your Report Properties Code Tab.......
Public Function ReplaceData(ByVal str As String, ByVal sData As String) As String
        Return System.Text.RegularExpressions.Regex.Replace(sData, str, "")
End Function

The str is the string you are searching for; and the sData is the whole data field that you are wanting to check.

Place this example code in your Textbox or Cell
=Code.ReplaceData("xyz", "xyz:Michigan")
on the report field more like this
=Code.ReplaceData("xyz",Fields!MyData.Value)
0
 

Author Comment

by:kalittaair
ID: 34916413
Planocz,

Firstly, thank you for your quick posting and I apologize for the delayed response. I've been out of the office.

This works great except when the data returned is NULL. In that case I get an "#Error" in my field. Sometimes the data coming back from the DB will be NULL. In that case it should do nothing, and just display no value. How can I handle that?

Also, any idea on how I can change the background color when the "xyz:" exists?

Thanks again.
0
 
LVL 27

Expert Comment

by:planocz
ID: 34919015
Change to this code

Public Function ReplaceData(ByVal str As String, ByVal sData As String) As String
        If IsNothing(str) then
           Return Nothing
        Else
           Return System.Text.RegularExpressions.Regex.Replace(sData, str, "")
       End If
       Return Nothing
End Function
0
 
LVL 27

Accepted Solution

by:
planocz earned 2000 total points
ID: 34919093
0
 

Author Closing Comment

by:kalittaair
ID: 34921512
All works great. Thanks for all your help!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction As you'll probably know, a data region in a SQL Server Reporting Services report can be linked to only one dataset.  This makes it troublesome when you need to display data from more than one dataset in the same data region.  SQL Serve…
Hi All, I am here to write a simple article to move SSRS (SQL Server Reporting Services) reports from one server to another. When I have faced the same issue to move reports those were developed by developer on development server and now need to …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 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