SSRS Report - Dataset Filters - sql-server-2008

I've written a report for SSRS and Im using dataset filters with expressions to filter the report info. I seem to either have this expression wrong or the filter is not working correctly:
=IIf(Parameters!DoctorID.Value = "All" Or Parameters!DoctorID.Value = "", "*", Parameters!DoctorID.Value)
What I want to accomplish with the above code is if DoctorID = ALL or "" (blank) then I want to omit it from the filters so I return information for all doctors. However, whenever the value of DoctorID = ALL, I'm returning no rows what so ever. It should be the case that i'm getting ALL rows since DoctorID is not a specific number.
Does the "*" (star) not denote an omitting of that filter? Am I doing something wrong here?
Thanks!

The filter formula you provide is only half the equation: what is the operator and what are you comparing this to? And yes, I haven't seen SSRS use asterisk as a wildcard.
Consider putting your filter into the query for the dataset. The SQL WHERE clause can get pretty powerful. I would write your filter into the query as
...
WHERE
#DoctorID = 'All' OR #DoctorID = ''
OR #DoctorID = myTable.DoctorID
This will also let you move to a multiple value parameter pretty easily.

Related

Tablix Return All Values Wildcard

I have a report that I want to filter on multiple parameter inputs(4 total). Currently I am using report parameter inputs to get the desired values from the user and the filter is being performed via the Tablix filters on the table. The problem I am having is that the 4 filters are treated as AND filters so if I want to search by just one parameter it will not return any values because the other 3 are blank. My thought is to use the return all wildcard for Tablix but I can't find what that is. I know with SQL it is just * but in Tablix * replaces the % wildcard. Does anyone know what the ALL wildcard is in Tablix or a better solution to this? Any help is greatly appreciated.
You should just be able to set each filter using LIKE as the operator and then comparing it to an expression like this..
= "*" & Parameters!myParameterName.Value & "*"
If the parameter is blank all records will be returned so only parameters with values will do any filtering.

IIF query expression using Like "*" for the True condition

I have a database which tracks employee QA. I'd like to be able to search by a single Staff Member, a whole team, or a Unit. I have three controls that correspond to those fields and only one can ever have a value at once. In my quesry I'd like to have threee expressions that will limit my results by one of those three fields. I'm adding just one to start and I've hit a problem.
I found this https://www.acuitytraining.co.uk/microsoft-training-courses/access/if-statements/ which seems to do what I want. Here is the code I'm trying.
IIf(IsNull([Forms]![MainMenu]![btnManagersMenu].[Form]![cmbStaffSelect]),
[UserLogin] Like "*",[UserLogin]=[Forms]![MainMenu]![btnManagersMenu].
[Form]![cmbStaffSelect])
Which works fine if the control has a value. (condition is false) If the dropdown has no value (condition is true) I get zero results. I suspect the problem lies with the Like "*" on my UserLogin field. Here is my query wizard and the buildler wizard for the IIF expression
Can anyone see why I'm not getting any results for the dropdown control being empty. To my thinking this should give me an unfiltered list of results. I have double checked my data and there are 137 records that should appear if I'm not limited by the staff selection.
The short version of this is if cmbStaffSelect has a value I want my records limited by that value. If cmbStaffSelect is blank I want to get all records.
Keep in mind that the iif function will always evaluate both the then and else arguments, before returning the appropriate value depending on the value returned when evaluating the supplied test expression.
As such, if either the then or else arguments have the potential to error when evaluated (regardless of the result of the evaluation of the test expression), then the iif expression has the potential to error.
As an alternative, you could use the Nz function to achieve the same result:
[UserLogin] LIKE Nz([Forms]![MainMenu]![btnManagersMenu].[Form]![cmbStaffSelect],"*")
Perhaps your IsNull([Forms]![MainMenu]![btnManagersMenu].[Form]![cmbStaffSelect]) is always returning false because cmbStaffSelect might be equal to empty string?
Try something like this:
IIf(Trim([Forms]![MainMenu]![btnManagersMenu].[Form]![cmbStaffSelect] & "") = "",
[UserLogin] Like "*",[UserLogin]=[Forms]![MainMenu]![btnManagersMenu].
[Form]![cmbStaffSelect])
This checks to see if the cmbStaffSelect is "" ... if cmbStaffSelect is null - it converts it to "" by appending an "" to the null value.
I believe your hunch is exactly correct. If you want your query result to return the * symbol for the UserLogin field; then alter your IIF statement to be: [UserLogin] = "*"

How to implement Having Clause in SSRS

I'm New to SSRS.
Im trying to create a report where i need to group by [DATA Flag] column which is working fine ,but once the data is grouped i need to set the DATA FLAG ="TotalCancellations" and there is another column CancellDays which i need to set it as <120 .
I tried
Option 1:-
So to achieve this i have added TWO filters one with
Expression : DATA FLAG
Operator =
and Value as TotalCancellations
and the other filter as follows
Expression : Cancelldays
Operator =
and Value as < 120
But its not working and giving empty result,i have records with Cancelldays <120
Option 2 :-
Right click on Group and in General Tab ,Group on Expression as below ]
Fields!DFlag.Value = "TotalCancellations" AND Fields!DFlag.Value <120
which didnt work :(
this is similar to writing having clause in SQL i believe but im not getting how to implement that here in SSRS.
i can add in SQL Query but its already a huge query with lot of unions so please suggest me if there is any way i can implement here in SSRS
Im using Matrix in SSRS 2008
Adjusting the syntax for your option 1 is probably the easiest solution. In the Group Properties, under the Filters section, enter these two filters:
Expression: [DFlag] (Text)
Operator: =
Value = TotalCancellations
Expression: =Sum(Fields!CancelDays.Value) [enter this in the expression builder] (Integer)
Operator: <
Value: 120
Putting all the filters in a single expression, like your option 2, can be useful if you need to filter by one criteria OR another.
Below are the filer expressions
and this is how group by is
The filter should be implemented at the tablix level, not at the group level.

How to apply multiparameter to ssrs report filter

I have a master that can be filtered using 4 different parameters. I used a iif statement to join all the parameters to filter the report.
The problem I am now having is when more than one paramater is selected, it tends to return values for the first parameter rather than for all
My paramter expression is as follows:
expression
iif(IsNothing(Parameters!Div.Value)=0,Parameters!Div.Value
,iif(isnothing(Parameters!St.Value)=0,Parameters!St.Value
,iif(isnothing(Parameters!Sp.Value)=0,Parameters!Sp.Value
,Parameters!Hc.Value)))
values
=iif(IsNothing(Parameters!Div.Value)=0,Parameters!Div.Value
,iif(isnothing(Parameters!St.Value)=0,Parameters!St.Value
,iif(isnothing(Parameters!Sp.Value)=0,Parameters!Sp.Value
,Parameters!Hc.Value)))
Any help will be helpful
I think what you are trying to do is something like this:
=IIF(NOT ISNOTHING(Parameters!Div.Value), Parameters!Div.Value,
IIF(NOT ISNOTHING(Parameters!St.Value), Parameters!St.Value,
IIF(NOT ISNOTHING(Parameters!Sp.Value), Parameters!Sp.Value,
Parameters!Hc.Value)))
Do you only want to check for one value?
I usually check each parameter separately so it uses all of them at once. Though there may be a situation where your theory is what you want.
If you want to evaluate all the parameters, just add them to the FILTER of the dataset, table, or group. Choose your field in the Expression and the Parameter in the Value.

SSRS Ignore Filters Based on a specific Filter used

Good day
I have a SSRS report that has 4 filters.
One of the 4 filters is a "Search Parameter".
When the user uses the "Search Parameter" (field/filter, types something in), I want to ignore the other three filters despite them having values or not.
I've tried CASE/SWITCH statements in the Expression of the Parameter (DataSet Properties), but no luck.
Does anyone have an idea on how I can get this done
The Filter is quick and convenient but only allows AND relationships between the filter criteria and you want an OR relationship here.
The good news is that you can make more complex filter logic by using expressions. We will create a boolean filter expression that evaluates to whether you want to filter the row or not and compare this to True.
Have only one filter criterion and click the expression editor button. Make the expression something like:
=IIF(IsNothing(Parameters!SearchParameter.Value), Fields!Field1.Value = Parameters!Field1Parameter AND Fields!Field2.Value = Parameters!Field2Parameter AND Fields!Field3.Value = Parameters!Field3Parameter, Fields!SearchField.Value LIKE "*" & Parameters!SearchParameter.Value & "*")
Make the expression type be Boolean, the Operator = and the Value True.