Select All parameter doesn't work in SSRS - ssrs-2008

I have a report which creates a list of Events for a specified date range and event type.
The date range and event type are parameters defined in the report. The date parameters (#DateFrom and #DateTo) work as they should.
The #EventType parameter however, which is defined as a list of values provided by a DataSet (with 'Allow Multiple values' checked), does not provide the expected behaviour when using the {Select All} check box. If I select one or more Event Types by checking several boxes on the list, the report will show the Events which match the specified Event Types correctly.
However, if I click the {Select All} box (which then highlights all of the other possible values), the report does not show the Events for all of these Event Type values. It seems to miss out several of the values which are selected by the {Select All} box. If I run the report specifically for those missing values, the report returns events matching those types. This indicates to me that there is not a lack of data for these types.
And for that reason, it looks to me like the {Select All} is bugged...or perhaps cached somewhere? I've tried deleting the report/parameter dataset and redeploying to no avail. It's worth noting that this behaviour happens locally before deploying it, too.
Has anyone seen this before, or does anyone have any suggestions?
EDIT - I should also mention that the parameter in question (#EventType) has no default value assigned.

How are you declaring your predicate for the variable? It should be be like:
where thing in (#Variable)
Where #Variable is a multi value parameter.
You could attempt to see if the values of the multi valued parameters are junked up somewhere as well by defining them. Generally the collection method of multi valued parameters can cause issues if there data types are different.
Also you may try to design your data set at runtime to build instead of being a static query. EG: Set up an expression for your dataset like:
="Select * from table where thing in (" & Parameters!Variable.Value & ")"
This would cause the parameter to build as part of a string and then evaluate at run time instead of from a traditional query.

Can't quite believe that this was the case, but the parameter which was passed to the SQL Server procedure was too small. It was defined as a VARCHAR(500) and needed to be bigger to deal with a large list of comma separated values. I changed it to VARCHAR(4000) and it's now functioning as expected.
Thanks to Djangojazz for pointing me to the direction of the parameter.

Related

Filtering a datasource using multi select wild character

Does anyone know if there is a wildcard character in AppMaker that can be used for all possible values for a field in a query?
I currently have a datasource that is being filtered based on the status using a multi-select widget. What I would like to accomplish is when all values have been de-selected I want to load all the records of that datasource without clearing the entire query in case other filters have been applied. I have it working in-a-sense that I have to explicitly construct my query as such:
widget.datasource.query.filters.Status._in = ['Status Value 1','Status Value 2','Status Value 3']
My current solution is loading the correct data when a value is selected and it correctly shows the union of the query as the values are modified. However, it selects all of the values in my multi-select; which I know is how it is supposed to work.
I tried using widget.datasource.query.filters.Status._contains = ''; and changing the assignment value to no avail. I even tried the opposite approach using _notContains
The intended outcome is to have a filtering dashboard appear much like any website where when no filtering is selected all records are displayed. I was hoping to find a wildcard character that would load all of the records. Just trying to find a way to mimic other website filters with all records when none are selected.
Thanks for the time!
So the easiest solution here is to set up your Multiselect as follows:
Options binding:
#models.YourModel.fields.Status.possibleValues
or if you don't have the possible Status values in your model then set your options binding to:
['Status Value 1','Status Value 2','Status Value 3']
Values binding:
#datasource.query.filters.Status._in
Now anytime you select any choices in the multiselect, the query will only include records that include the selected choices. And if you deselect all choices the query will ignore that filter or treat it as an empty array of values, therefore returning all records unless you applied other filters.

SSRS 2008 R2 CountRows(GroupName) doesn't work

I created a report for SQL Server 2008 R2 Reporting Service, in design mode this report looks like :
You can see I have an expression in the left cell of second row from last, the expression is:
=CountRows("GroupbyClassification")
When I preview this report, it give me this error:
The value expression for the textbox ‘textbox7’ has a scope parameter that is not valid
for an aggregate function. The scope parameter must be set to a string constant that is
equal to either the name of a containing group, the name of a containing data region, or
the name of a data set
This error is caused by CountRows("GroupbyClassification"), from
http://technet.microsoft.com/en-us/library/dd255215(v=sql.105).aspx you can see CountRows can work on a group. But why it doesn't work for me. If I just use CountRows(), it at least works without error.
It's because GroupbyClassification isn't the current or containing scope. It is the child scope. If you use =CountRows("GroupbyLocation"), it will give you the same results as =CountRows() because GroupbyLocation is the current scope. Since there are multiple GroupbyClassification Row Count values for each GroupbyLocation group, the report can't know which one to return when you specify the GroupbyClassification scope.
Child scopes can only be used in nested aggregates. So, you could use =sum(CountRows("GroupbyClassification")), but that would give you the same counts as =CountRows("GroupbyLocation") and =CountRows().

How do you specify the available values parameters in SSRS?

In SSRS ,I'm trying to build a report using this Parameter screen. One of the parameters takes 5 values, shown below:
Src
However, it's not working.. and I'm not sure why. I also don't understand what's the difference between "Available values" and "default values" ? Any tips appreciated, thanks
Available values are those values that you allow that parameter to have. They are selectable from a drop down list. You can either specify them manually, as you have done, or populate the available values from a dataset.
Default Values holds the initial value that the parameter will be set to. This will be one of the available values. In your example you might set the default value to 0 to indicate a default of "No repsonse to survey". If all the parameters have default values then the report will run automatically.
Now you say it is not working but you don't define what not working means. Please edit your question to define what is happening and what you actually want to happen.
I'll take a quick guess that the values returned aren't being filtered by your parameter selection? If so, you have to use your parameter in the query or the Filter expression of your dataset.
For example, if your parameter is called Response then the dataset query should be something like
SELECT *
FROM Responses
WHERE ResponseValue = #Response

Apply a Report filter in code

My particular, specific issue is probably too localized, but the general question I'm about to ask is something I'm sure others will ask and have wondered:
General question: In Sql Server Reporting Services, is it possible to apply a filter to a report in code? If not, is it possible to use branching in the report filter based on the value of a variable, and can you point me to documentation or explain how to do it.
My specific example follows, to expand on what I mean by the above, in case I worded it badly:
I'm learning SSRS and the docs and Google are coming up short.
The desired effect is that we have a report based on an incident tracking system. In this system, we have various teams that can track incidents: IT Ops, Development, Security, etc. Each of these teams have team members assigned.
We have a base report that displays ALL incidents.
We have added a boolean parameter named "LimitByTeam", which produces a CheckBox on the report as you'd expect.
We have added a String parameter that accepts multiple values. The allowed values come from a data set that lists the teams. This has added the expected drop-down list to the report, allowing users to select one or more teams.
We added a dataset that contains team and team member.
If the CheckBox is NOT selected, we want to display all incidents. (The default)
If it IS selected, we want to have the report to filter based on the login ID of the person who created the incident ticket.
Were I to do this in SQL, I'd do it as
Select
(ticket fields)
From
Table
WHERE TicketCreator IN (
Select LoginId FROM TeamMembersTable
WHERE TeamName in ('IT Ops', 'Developers'))
In SQL, or in VB, etc, this would be simple.
In SSRS I'm not figuring out quite how to do this. I've gotten as far as figuring out that I can use Custom Code to do more complex logic using VB (and it appears to be VB.NET. HOORAY! Familiar territory)
So I've added custom code and verified that I can read the value of the report parameter, but I can't figure out for the life of me how to apply a filter if the parameter value is True. Here's what I've got.
Public Sub ApplyTeamFilter()
' Report.Parameters("LimitByTeam") is a
' boolean report parameter that I'm able to access
' so I've got the IF statement worked out
If Report.Parameters("LimitByTeam").Value = True Then
' Pseudo-code - I'm looking for something like Report.Filters.Add(filterstatement)
' Alternatively a way to change this to a function to return a list of items from
' the Team MembersTable table and use it in a custom expression.
End If
End Sub
The problem is that I can't seem to find a Filters property on the Report object, or any method that lets me find it. Since I couldn't find it there, I expanded my search to everything in this section of the MSDN library and can't find it, or anything even remotely resembling a way to do what I'm attempting.
I'm also trying to do something like this because I think I see a way to use this function:
Public Function IsLoginIdInTeam(ByVal LoginId as String, byVal Team As String) As Boolean
' Report.Parameters("LimitByTeam") is a
' boolean report parameter that I'm able to access
' so I've got the IF statement worked out
If Report.Parameters("LimitByTeam").Value = False Then
Return True ' Default
Else
' Access the TeamMembers table and look for a match
' Something like
' Convert.ToBoolean(Report.DataSets!TeamMembers.Compute(Count, "TeamName = '" & Team & "' AND LoginId = '" & LoginId & "'")
End If
End Function
But I can't figure out how to access the Data Sets in the report, either, much less the syntax for interacting with them. The pseudocode works with a System.Data.DataTable, but I suspect SSRS DataSets are a different beast.
Am I missing something blindingly obvious? Should I be giving up on filtering this way in the report, and try another track, like changing the original query in the DataSet?
I'm not a huge fan of boolean parameters in SSRS (or BIT in SQL for that matter.) You can't write things like
WHERE #MyBool OR #MyOtherBool
It needs to be
WHERE #MyBool = 1 or #MyOtherBool = 1
So if I have an SSRS report with a boolean called MyBoolParam and a multivalue text parameter called MyMultiSelectTextParam , a SQL query like this will work:
SELECT
MyField,
MyOtherField
FROM
MyTable t
WHERE
#MyBoolParam = 1
OR
t.MyField IN ( #MyMultiSelectTextParam)
(My preferred alternative to boolean parameters is actually a string with possible values, but it would be handled in the query in the same way.)
If you can't easily change your SQL query (such as using a third party SP) then you can also accomplish the same thing by adding a filter to the SSRS DataSet. Right click on the DataSet in the Report Data pane and look at the Dataset Properties. The Filters pane will let you add criteria that are evaluated for each row. I haven't used these as much with multivalue parameters, but the IN Operator should work for that.

SSRS field scope issue

I have an SSRS 2008 R2 report that uses this expression in a table:
=Lookup(Fields!DataSet1Date.Value, Fields!DataSet2Date.Value, Fields!DataSet2Price.Value, "DataSet2")
I have 2 data sets and am using the Lookup function to get data from one dataset based on the date in another dataset.
My problem is that this works on machines that I have tried it on, but others are getting errors like this:
Error 1 [rsFieldReference] The Value expression for the text box ‘Col_D2Price’ refers to the field ‘DataSet2Date’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope.
Error 2 [rsFieldReference] The Value expression for the text box ‘Col_D2Price’ refers to the field ‘DataSet2Price’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope.
What other things can we do to troubleshoot this issue? We are all using the same 2008R2 version.
I oftern get this "phantom" error when using the LookUp function. I call it phantom as no where can I find a reason, but there you have the error pop up.
The only way to get around it in my cases is to use the secondary function LookUpSet.
Hope I've helped.
Edit:
Furthermore you've intrigue me so I've done some research:
The lookup function is only for 1-to-1 relationship.
The loopupset funcrion is for 1-to-many relationship.
The multilookup function is for many 1-to-1 relationships, i.e. an array of single values where there is only 1 value in the second dataset. Not relevant but quite interesting.
Also I came across a potential fix. This being on the new machines try and open the datasets in the report and refresh all fields in the dialog box. For some reason this may relink the fields to this expression. Go figure...Blockquote