In SSRS, how do I make a drop-down parameter visible only if a previous parameter has one option chosen? - vb.net

I have a situation where I want to make a drop-down parameter visible only if a previous multi-drop-down param. has one choice chosen(out of many choices).
Wht i've triedso far is to set the Default Val. for the drop-down parameter to be this:
=iif( Parameters!AccountIDs.Count >0 , 1, Nothing)
But it's not working. any tips appreciated, thanks

You won't be able to make a parameter disabled or enabled like this. (At least not without getting really complicated and hacking the page a bunch)
But you can make the second parameter have dynamic available options. Then make it just a sinlge option such as "<Not applicable>" and select that if the earlier parameter has multiple values.
You will need to create a dataset that returns the available parameters. Something like this might work:
SELECT
'<Not Applicable>' AS ParameterValue
WHERE
#ParamOneCount > 1
UNION ALL
SELECT
SourceName
FROM
someTable
WHERE
#ParamOneCount = 1
(You could change replace the second SELECT with multiple selects to have multiple hard coded values.) Then in the parameters for this dataset, set one of the parameters to be called "ParamOneCount" and set its value to be =Parameters!Account.Count

Related

SSRS Multiselect parameter error

I have a project that I need to add a param to that accepts multiple values. While this should sound pretty easy it is not working.
Here is the param: #queue_group varchar(100)
And here is how it is used: and g.extension in (#queue_group)
Now when I manually do it like so: and g.extension in ('700', '702') it works just fine. I have to make the numbers a string because of how the column was setup it has some string values in it such as *86 that breaks when I just do 700, 702.
Now I set up the param in SSRS giving it available values and allowing multiple select but every time it doesn't work because it can't find any results. The ultimate error is a divide by zero which is because it isn't finding any records.
How can I make SSRS mimic my manual behavior of '700', '702' which when I remove the param and enter that manually it runs just fine.
In SSRS I've tried Available Values CS = 700, CS = '700', CS = =Cstr(700) and CP = 702, CP = '702', CP = =CStr(702).
I've now tried setting up a table and using that as the defined values for the parameter. It now works when I select a single option and returns results. whenever I select 2 it returns me 0 results.
I'm at a loss.
SSRS can support multi-value parameters without much extra work so long as the dataset is in ssrs.
Here is a link to the tech net on it:
https://technet.microsoft.com/en-us/library/aa337396(v=sql.105).aspx
What happens is that SSRS passes the whole query to the sql compiler, this means that the replacement of the parameter with the multi-value string happens before compile. So I don't think that's the problem, because If it were an error in the way the multi-value param was presenting the data to the compiler it would not be a divide by zero.
Instead I'm thinking this has to do with how the parameter is populated. You have the param set to a text field, so people are expected to enter their own values. However SSRS handles the formating for a text field before it's sent to compile, and I'm guessing that's what tripping you up.
If you enter "402,407" without the quotes into the param at compile time it will be transformed into:
and g.extension in ('402,407')
That would not return any results. If this is just a report you use, you could enter: "402','407" without the double quotes and at compile time it would transform it too:
and g.extension in ('402','407')
The better solution would be to create a data set for the param, set the parameter to use that data set as it's list of available values, and check the multi-value property for the param. That way you would select multiple values from a drop down, and the user wouldn't have to mess with the string formatting.

Use single value of parameter List in queryString

I am using JasperStudio 5.6.0.final and the report is not generated dynamically from java code.
I have a problem with getting single value from parameter.
In the report I have a parameter A of a type List.
It is not a problem to use it in a clause as IN statement:
AND $X{IN, USER.ID_USER, A}
But I have a problem to get a single value from that list.
I know that my List has always 10 values.
So I want to use it in query, but I don't know how to write the statement:
AND USER.ID_USER = *first_value_of_list_A*
e.g.
AND USER.ID_USER = $P!{Atrybuty}.get(1)
doesn't work
I tried also to assign parameter value to a variable, but as I know it isn't possible to use variables in queryString.
So my question: How to get single value from parameter List in queryString.
What you need to do for this is use
AND $X{IN, USER.ID_USER, A}
Set A type as Collection and that will allow you to even have a single selection or multi selection or just a single value.
Hope that this helps.

BOBJ. Change object underlying field based on what is selected in the query

In BOBJ is there a way to change the formula of the object based on what's being selected in the query?
For example, TradeValue usually equals to dbo.Trade.TradeValue, but if SalesPerson is selected in the query along with TradeValue, I would like TradeValue to be dbo.Trade.TradeValue * Salesperson.Percentage.
Any workarounds suggested will be much appreciated.
There's no way for a particular object to detect the presence of another object in the query, so you would need two objects for TradeValue and TradeValue * SalesPerson.Percentage.
The only workaround I can think of is to create a prompt that asks the user whether SalesPerson.Percentage should be included in the calculation. Something like:
TradeValue * case when #variable("Multiply by SalesPerson Percentage") = 'Y'
then SalesPerson.Percentage
else 1 end

Filling parameter with value from Zeconfig_var table

I have the following selection parameter:
PARAMETERS: p_ver(2) AS LISTBOX VISIBLE LENGTH 5.
I would like to populate it with the results from a ZECONFIG_VAR table.
At what point would I do this. Selection Screen Output, Start of Selection, or other. I am trying to allow users the ability to decide what version of the web service they would like to call. The config table will have different url's for the different versions.
I have looked at this Answer and the tutorial provided does not make sense to me.
I would do it at the event INITIALIZATION
However, it may be even easier to just create a search-help, and assign it to p_ver using the following:
parameters: p_ver(2) visible lenghth 5 MATCHCODE OBJECT zshelpname.
Esti is right that you probably want to fill an internal table from the DB table during INITIALIZATION.
But to the populate the listbox parameter, you need to put the call to VRM_SET_VALUES in AT SELECTION-SCREEN OUTPUT.

Passing multivalue parameter to a subreport

I'm having a problem when working with multivalue parameters between reports.
I have a main report in which I have defined a multivalue paramer, which I use to run a SQL query to populate its dataset. The parameter is used in the WHERE clause in the following way:
WHERE values IN (#parameter)
It's working fine and it retreives the expected data.
Then this main report passes this parameter to a subreport. The parameter is also defined as multivalue in the subreport and, as far as I can see in the parameter's dropdownlist it receives the values in the right way. Something like this: A, B, C
The thing is that the query that populates the subreport's dataset returns nothing.
It also has a WHERE clause defined as in the main report (which is already working)
WHERE values IN (#parameter)
If I run the query manually, hardcoding the values to something like this:
WHERE values IN ('A', 'B', 'C')
it works, but when I try to use the parameter it doesn't. So, somehow it's losing the format or the values in the way.
I tried this solution in the subreport's dataset definition, which was proposed in another thread:
=join(Parameters!<your param name>.Value,",")
But it doesn't work for me, the dataset is still empty.
Any ideas about what I'm missing?
Thanks! :)
This should "just work." Make sure that the Parameter in the subreport is set up as multivalue, and I usually use the exact same query as in the parent report to provide "Available Values."
Check that you are passing the entire parameter to the subreport: In subreport properties on the parent report, the parameter's value should read [#MyParamName] not <<Expr>>. If it reads as the latter, edit the expression and make sure it doesn't have a (0) at the end. but =Parameters!MyParamName.Value is correct, not =Parameters!MyParamName.Value(0)
Just created the report from scratch again and it worked. I must have forgotten something in the middle.
Anyway, just in case somebody needs it, the two parameters, the one in the main report and the one in the subreport , must be defined as multivalue.
Then in your query you should use IN in your WHERE clase, something like this:
WHERE field IN (#parameter)
And nothing else is needed. I didn't need to do the following:
=join(Parameters!<your param name>.Value,",")
It just worked for me
I think I know what you did, as I was drawn here by having the same problem.
The subreports were setup fine, but when entering the parameter binding in the parent report, the Value drop down did not offer my parameter, so I used expression builder to select it. This left the grey << Expr >> marker in the value and would only work when I had only one value selected from the list. When I replaced this with [#MyParam] it worked fine regardless of the number of values selected. When I had a look at the value expression builder had created a bit closer it had =Parameters!MyParam.Value(0). Removing the (0) also fixes it.