SSRS: How to disable a parameter (nvarchar) based on another parameter - sql-server

Im making a report that has a parameter
DateFrom:
Date To:
Handled: Successful or Unsuccessful
GroupName:
AgentNamme:
What I want to do is if I selected in Handle 'Unsuccessful' the GroupName will be disabled. I tried looking for answers on the net but failed.

Hi I think you can achieve this using Optional Parameter feature of SSRS.
or you can change the data set in such a way. you can edit the query and check there.
Example- Optional Parameter

You can't disable a parameter in SSRS. You have to provide a placeholder value to it instead, usually a null value.
The available values for GroupName should be based on a query to get all of the possible group values, unioned with a null value for N/A. When Handled = Unsuccessful, the only possible value for GroupName should be N/A.

Since its impossible to disable a parameter I just query a default value if Hanled=Unsuccessful.

Related

remove 1st item (or any item) form multivalued parameter item list in SSRS

I have a multivalued parameter named as Graduation_Year. It is a optional parameter. So I have used the "Please Select" as the default with value 0. Therefore I have used below query to make it optional and filter values only when a real value is entered.
EH.Pwks_year_of_graduation IN (#GradYear) OR 0 IN (#GradYear)
But here user has to de- select "Please Select" get the correct result.
I tried to filter the Graduation_Year parameter using dataset parameter expressions. But it didn't work.
Please suggest a method to filter out the 1st item in the multivalued parameter list (it can be used with below expression).
=iif((Parameters!GradYear.Value(0)="0" And Parameters!GradYear.Count>1)
,**Filtered Parameter value list**
,Parameters!GradYear.Value)
All I want is to remove Parameters!GradYear.Value(0),
when Parameters!GradYear.Count>1
form the multivalue parameter before it is considered in the query.
Thanks
Mathee
You have started off the wrong foot and now you are trying to fix something you shouldn't have done anyway.
The provided value **Please Select** should be a prompt and not a specified value for your parameter.
If you go to the parameter properties there is a property called Prompt specify Please select there.
Now when you execute the report it will show the parameter as follow:

Dynamically Change Where Clause Condition Based on Parameter Selection (SSRS)

I have built an SSRS report, but am unable to get over one hurdle. It may be simple, I am just unsure of how to solve this.
I have a parameter drop down that allows the user to select one of two options, if they select one option the a portion of the where clause should change, and if the other is chosen it would change again. I will post it below :
If master is chosen :
WHERE myId=1 AND myJournal IS NULL
If Idol is chosen :
WHERE myId=1
So basically just adding a condition and taking a condition based on parameter selection....
This seems very rudimentary, I just can't seem to figure it out.
Thanks for any input
How about
WHERE myId=1 AND (myJournal IS NULL OR #Parameter = 'Idol')
assuming your parameter value get set to Idol of course
The way this works is:
If #Parameter = 'Idol', then the OR clause in the brackets will always be true, regardless of the myJournal value. This reduces the entire WHERE clause to WHERE myId=1 AND true, which is the same as WHERE myId=1.
However if #Parameter = 'master', then the OR clause in the brackets will only be true if myJournal IS NULL as #Parameter = 'Idol' is always false. This means the OR clause can be thought of as equivalent to simply myJournal IS NULL.
This reduces the entire WHERE clause to WHERE myId=1 AND myJournal IS NULL, which is what you are after.
You don't provide any information about the way you want to perform the query.
Do you want to do it with an ajax call?
In this case you should have a selectcombo which will set the needed query string and pass this with an ajax request to the php file that will query the database.
If you want some help we need to have some more information about what you are trying to achieve.

Conditional report parameters in Reporting Services

I have a report which requests a parameter value for customerNo. The report should return all values by default.
Once the user provides a single customerNo value, then it should display the specified record only.
I've found solutions for Multiple selection, but couldn't find for single text box entry.
Thanks guys..
Report Design
Change the report parameter to allow NULL:
Modify the WHERE clause of the data set to check NULL parameter value:
Report Execution
When the report is run, users can check NULL for all rows:
Or rows matching a specific value:

how to set SSRS Report parameters to be optional i.e Non-Mandatory field in SSRS 2005

Please help me to set the SSRS Report parameters to be optional i.e Non-Mandatory field in SSRS 2005.
Set the parameter to 'Allow null value' under General section. Null according to SSRS means it does not have to be set, thus making it optional.
Then post something like this in the predicate of your SQL syntax:
Where column = isnull(#Variable, column)
This lets the dataset know that if the variable is set then use it, else have an operator to have the value equal itself. I am certain this works in SSRS 2008 and 2012, not sure of 2005 but I would assume it may be there.
As Hiten suggested there is nothing exactly we can call as optional parameters but if you want users to see this parameter as optional, use formula or case statements.
Parameterized stored procedures with some defaults or null value can be used to achieve the same goal.
Further to djangojazz (dig the name, btw) - If the dataset is based on a SharePoint list (which doesn't support Query parameters, afaik), you can use the following formula in the Value box of the Filters section of the Properties dialog in whichever data region (e.g. Tablix) is invoking the parameter:
=IIf(IsNothing(Parameters!myParam.Value),Fields!myField.Value,Parameters!myParam.Value)
Neither of these answers helped, nevertheless I found the solution here:
Open the report for editing in Visual Studio.
Expand the Parameters node and rename the affected parameter to ParameterName1.
Set AllowBlank and Nullable to True if not already set.
Deploy the report.
Rename the parameter back to ParameterName.
Deploy the report.
After adding a parameter to your report and checking 'Allow Null Value',you can then add a filter to the dataset where the below expression is added to the value field for the filter
=IIf(IsNothing(Parameters!Param.Value),Fields!Field.Value,Parameters!Param.Value)

SQL Reporting Services 2005 - Non-queried Report Parameters

I'm working on a report in Reporting Services and I can't figure out why I'm having trouble with Non-queried report parameters.
I'm trying to get the current year and have tried:
=YEAR(TODAY())
=DATEPART("yyyy",TODAY())
I have also tried TODAY instead of TODAY()
All of these seem to break the Year dropdown on my report. I thought if something was wrong it would just not get the correct default... but nope, it breaks the whole field.
Any thoughts? articles?
UPDATE:
Wait, wait, wait... the weirdest thing. The Year parameter is the second parameter of this report. And its grayed out (with no value) UNTIL I select the first parameter (im my case "category"). Am I somehow telling the Year param to do this? or does SSRS 2005 process the params in order? I don't think I ever noticed this before.
UPDATE 2:
Please see all comments
=DateTime.Today.Year
should work as well.
Edit: Bruno - i have the same behavior as you are seeing. I created a sample report with a string first parameter with no default value, and a string 2nd parameter with a default of =DateTime.Today.Year. When I have the one with the default as the 2nd parameter in the order, it shows up empty and disabled.
I was able to fix this problem 2 ways: first by adding a default of =String.Empty to my first parameter, and the second way was to just change the order of the parameters.
Not sure if this behavior is by design or a bug - but like you said, I hadn't noticed it either until today when you pointed it out in your question.
Try:
=Year(Now)
I'm not sure if this is what you need, but it worked for me. I used it to form a date string so I used =Year(Now).ToString().
SSRS does process the report parameters in order - order can be important if you have dependencies between your parameters.
From MSDN: "Parameter order is
important when you have cascading
parameters, or when you want to show
users the default value for one
parameter before they choose values
for other parameters."
So, it will always wait until you have a default value for your first parameter or you enter the first parameter's value, before it processes the next one, and so on.
http://msdn.microsoft.com/en-us/library/cc281392.aspx
I found the by making sure that ALL of my parameters had at least some default value, then you will not experience they greyed out datetime picker. So, every parameter before your datetime paremeter in order needs to have a (default) value or it will not work.
Def due to order of evaluation of parameters.
Simple workaround ; in the parameters tab you can change the order of the parameters - this will move the date pickers to the top of the list and are then enabled straight away, on my server at least.
Someone raised the issue of basing a date filter on a queried default value - if you do this, you will notice a very annoying knock-on effect of getting screen refresh any time the dates get changed, before you have a chance to requery the reports.

Resources