ObjectSharp Blogs

You are currently viewing

Dave Lloyd's 2 Cents

A .NET Developer's Perspective


SRS Filters

I have found a lot of students and clients are not getting the most out of filters in there reports. So I thought I would explain a bit about how useful they can be. There are two places you can put a filter in a report.

  • Data Region (Table, Matrix, List, Graph, Grouping Level)

Applying a filter to a DataRegion means I can show different views of the same data. In other words I can create one Dataset and let it feed multiple regions in my report. Say for example I need a report for management that shows the breakdown of Salaried employees vs hourly. They want to see two pie charts one will show the number of salaried employees by department the other Hourly. Instead of creating two queries one that selects salaried employees and one that selects hourly. I can just select all the data into one Dataset and filter the separate Graphs.

 

When you set the filter don't forget you are applying an expression so the value must begin with an equal sign. This is a common source of frustration the first time people use filters.

I can reuse this data in different ways throughout the report. In a matrix to show the number of employees by region, in a table sorted by Hire Date. All from one dataset.

  • DataSet

You can apply a filter to a Dataset, which at first seems odd. Doesn't the Dataset already have its parameters. Why would I filter the report again? When you create a Cached Instance or a Snapshot the report is stored with its data and the parameters cannot be changed. However filters can still be applied to the report. Filters will use the current report parameter values to filter the report instead of creating a new cached instance or snapshot. This can be useful to avoid creating multiple versions of the same report in the cache.

Comments

  • dave December 7, 2006 1:41 PM

    I can't get the filter to work for a table OR a dataset ... or it works sporadically.

    Example (when attempting to filter a table):

    =Fields!SalaryBenefits.Value = =CDbl(0)

    This works. It only shows the rows where SalaryBenefits is zero. But if I change it to

    =Fields!SalaryBenefits.Value > =CDbl(0)

    then it shows nothing. There are actually fields that have SalaryBenefits > 0, but they do not appear. Nor does the 0 one appear.

    ????

    The only filtering I have been able to get to work is setting an expression for the Hidden property of a detail row in the table. But this is not ideal.

    P.S. I had to use CDbl(0) or it complained that I was trying to compare a double and a string.

  • dave December 7, 2006 8:18 PM

    Never mind, I discovered that the filters DO work, just not in preview!

    Ghaa .. this isn't the first time preview has fooled me into thinking something is not working. Calling functions using "Code" also does not work in preview.

    It might be nice if Microsoft made preview work the same as the deployed report. I will typically not deploy a report unless it renders correctly in preview mode. When you have a large number of reports, it is invaluable. It's disturbing to find out it may not reflect reality.

  • dave December 8, 2006 9:54 AM

    I was about to reply to you so thank you for letting me know you found the issue. I have had preview behave differently then the final reprt also but not when using code to call an external class. Do you have your DLL in the correct location for the Designer. Take a look at this blog entry. http://objectsharp.com/blogs/dave/archive/2005/02/09/1408.aspx

Leave a Comment

(required) 
(optional)
(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS