SSRS: is there a way to display a multivalued parameter in a table? - reporting-services

Using SSRS 2012
I have a multivalue parameter in a report and I would like to make it the source of a table. Is there a way to accomplish this? I'm coming to the conclusion that one cannot make the data source of a table anything except a dataset.
I tried to make the multivalued dataset (source of parameter) filtered by parameter but that gives a forward reference error (makes sense).
I am now trying to set the visibility property on the table's single text box like this, so it will only make the values visible that are one of the chosen parameter values:
=IIF(Fields!MODALITY.Value = Join(Parameters!Modalities.Value,","),True,False)
but they are all shown (alway true?). Any ideas on how to show a list of the values picked from a multi valued parameter in the report as a table (not just a delimited string in a text box)?

The data source of a table will always be a dataset, but you can use the parameters in a dataset. Something like
select * from dbo.split3(#parameter)
where split3 is a csv to table function, like one found on http://blogs.msdn.com/b/amitjet/archive/2009/12/11/sql-server-comma-separated-string-to-table.aspx

I found an expression that works for changing visibility so that my table shows just the elements in the multivalue parameter that were selected. Perhaps there's an easier way.
=IIF(Instr(","+Join(Parameters!Modalities.Value,",")+",",","+Fields!MODALITY.Value+",") <> 0,False,True)

Related

Microsoft Report Builder: How to display selected chosen values from a multi-value parameter in a table?

I'm using MS Report Builder v3.0 to create a report. As part of this report, I have a multi-valued parameter (named #Diagnoses). The labels and some of the values (truncated by the size of the display boxes) of this parameter are shown below:
What I would like to be able to do is display the labels / values the user chooses in a 2-column tablix (I've tried using separate textboxes for the labels / values but the results are mis-aligned).
However, this does not appear to be straightforward. The closest method I've found is this one, which stores the user's choices in an internal parameter in xml format, then queries this parameter to produce a dataset from the xml.
So, I created the xml-producing internal parameter like this:
...and I've created a dataset based on this data, with the following query:
But now when I put these values into a tablix, the labels and values are now on separate rows, like this:
Does anyone have a straightforward way of sorting this out?
Best Wishes
C J
OK - I've solved it (it's not pretty, but it works!)
Basically, the problem comes from having to use the join statement when creating the xml - you can't really put both the label information and the value information on the same row in the xml.
To get round this, you have to use two internal parameters to create two datasets - one for the labels column, one for the values column. The method for creating these is essentially the same as that shown above, except for the values parameter, the expression for the default value is:
...and for the labels parameter, it's this:
(by the way, make sure you set the available values to "None" for internal / hidden parameters - the expressions here are for the default values)
Then, when you create the values dataset, you use the following syntax in its query:
...and similarly for the labels dataset.
Finally, in the report, you create one matrix from each of the two datasets, then put them next to each other, using fixed row heights and setting "can shrink" / "can grow" to false so that they look like they're in the same table:
I hope this helps somebody!

Display Parameter in SSRS Report

When a user runs the report, they can select a multi-value parameter. I know I can use Parameters!Value.Label(0), Parameters!Value.Label(1), etc to display the each of the values based on their location within the array, but the number of the values changes based on how many values the user selects.
The report separates each value onto a separate page. I'm looking to (a) have an expression that identifies which value's info is displayed on the page, and (b) an expression that labels the tab as the value when the report is exported to Excel. I expect the same expression would work for both.
I believe I should be using Array.IndexOf(Split(Parameters!Value.Label.ToString(), ","), Parameters!Client.Label), but just get #Error as the output when the report renders. I'm not sure, but it seems like the Array... expression would only identify the location within the array.
Could someone offer some insight into where the syntax is wrong? I'm not sure if the issue is syntax or it's an issue of how to specify which dataset to use in the expression.
Thanks.
This is what you should use
=Join(Parameters!CSR.Label, ", ")

Using column from main dataset as multi-value parameter in subreport

Hi I am using SSRS 2008.
My set up is MainReport with dataset1 and 1 parameter - OrderID. One of the columns in dataset1 is ShippingID.
My other report called - SubReport has 1 multivalue paramter - ShippingID.
I am trying to use ShippingID from Main report as multi-value parameter for Subreport.
I tried different threads here but mostly they are diffrent than my scenario.
How do I go about setting this up, is that even possible?
I have been trying to set it up for whole day but unsuccessfully.
In my scenario one Order can be on multiple shipments.
One of the things I tried is creating new multi-value parameter in MainReport - call it shippingIDs_sub and mapping its default value to dataset1.ShippingID. But when I try to run report I get error "The 'shippingIDs_sub' parameter is missing value" - because my MainReport would sometimes return NULL in ShippingID column.
My scenario is very much similar to this
SSRS passing parameter to subreport
although I sometimes get NULLs in the column used as source for multi-value parameter.
Is there any way to filter out NULLs and run subreport only for existing IDs?
In the Action where you call the sub-report, where you map to shippingIDs_sub, use an expression to pass some valid value whenever the value in your dataset is NULL.
=IIF(IsNothing(Fields!ShippingID.value),"Some Valid Value",Fields!ShippingID.value)
As to this:
Is there any way to filter out NULLs and run subreport only for
existing IDs?
No, you can't turn off the ability to go to a subreport, but you can "hide" it by changing the appearance of whatever your user clicks on so that it doesn't look like it's clickable. For example, in our reports, when something is clickable, we make it underlined in blue. So if I don't want to user to click it, I just make it the same font color/style as all the other text. But it doesn't stop a determined user from clicking on it anyway if they want.

SSRS: Can I know if user selected "ALL" in multivalued param?

Customer wants me to repeat the parameter values in the page header of the report. But if they just choose "Select All" on a multi-valued parameter, they want the text "Any" listed.
For example, one parameter has a fixed set of 9 values. I hard-coded the expression for a text box to:
="Room Size: " &
iif(Parameters!pRoomCap.Count=9,
"Any",
Join(Parameters!pRoomCap.Value, ", "))
How can I do this if the parameter source is a query of unknown size?
Try this out. You need to compare the total number of parameters in the dataset to the count of selected parameters. The following assumes that your multivalue parameter is using a dataset called "dsRoomSizes"
="Room Size: "
& iif(Parameters!pRoomCap.Count = count(Fields!pRoomCap.Value,"dsRoomSizes"),
"Any",
Join(Parameters!pRoomCap.Value, ", "))
This expression will work in the page header/footer.
UPDATE
In the interests of finding a solution to your problem, the following should work for you. It feels hackish and I encourage you to keep research alternative methods but this will work:
Create a second multivalue parameter and name it something like "pRoomCap_hidden".
The source of the parameter is the exact same query
In the parameter properties, setting the default values to the same query
Important: Set the parameter visibility to hidden
This will create a second multivalue parameter in your report that is exactly the same as your initial multivalue parameter only this parameter list will have all values selected by default.
Enter the following expression in a textbox in your header:
=IIF(Parameters!pRoomCap.Count = Parameters!pRoomCap_hidden.Count,"All",Join(Parameters!ReportParameter1.Value,", "))
The above will compare the selected values in each parameter list. If the lists contain the same selected values then that indicates that "All" have been selected in the first list.
Like I said, it is hackish but it definitely works. Until you are upgraded to 2008, this might not be a bad workaround for you.
Can you compare the count of the parameter to the count of the dataset you pull the parameter values from?
I unioned my dataset for the parameters with one which I created manually with a "select" statement - I was then able to force the value to be something like -1 or null.
Then simply check if the parameter contains -1 or null and replace the value in the header with the replacement text.
BTW- I am now using SSRS 2008 R2 and this solution worked for me. My report uses three datasets; but only one in the tabilx that I needed to hide a row in. After long hours of searching and many, many, many unhelpful for wrong answers; the solution of creating a identical parameter only hidden (I marked it as internal) and then comparing to the exposed one is brilliant and easy.
Thank you very much!

Reporting Services - setting a field value dynamically based on parameter

I need to build a report that shows data in four grouped levels. The tricky part is: the actual fields to be displayed on those four levels are to be passed into the report as parameters.
My main issue right now is this: how can I tell a textbox on the report to not display the value of the parameter #X, but the value of the field by the name which is specified in parameter #X?
So if I pass in #X = 'Agent', I don't want to show 'Agent' on the report, but really
=Fields!Agent
but how can I do that? It seems to me that those value expressions are all pretty much hardcoded - is there a way to define
=Fields!(#X)
or something like that - show the field which corresponds to the name passed to the report in parameter #X ?
This is probably absolutely silly - but I'm hitting a brickwall right now and can't seem to find a way around it....
It is
=Fields(Parameters!X.Value).Value
as specified here
Edited to be correct: I forgot once you use an = (expression) you have to address the parameter differently.
Is the source data for the report arranged in such a way that you could define a second datasource which looks up the field values for parameters 1-4 and returns them as a single row, to which you could then refer in the report using the first syntax?
=First(Fields!Param1.Value, "Param_Lookups")