问题
I want to generate a multi-row table with a multi-value parameter.
The only thing i can do now is passing the specified parameter into every row like below:
=Parameters!P.Value(0)
=Parameters!P.Value(1)
...
=Parameters!P.Value(n)
Is there a way to do it dynamically?
回答1:
Interesting question, the only I can think of is converting the parameter array into xml in a dataset, and then converting it into a table via xml nodes.
The data set parameter (lets call it @par) then should be set in a expression as:
= "<n>" + join(Parameters!P.Value,"</n><n>") + "</n>"
Then the query for the dataset will be this:
declare @parxml xml = @par
Select p.query('./text()')
from @parxml.nodes('/n') as T(p)
this will provide a table with one row per each selected parameter value.
回答2:
Finally i've found a good solution.
(remember P is a multi-value-parameter .. es. P=a;b;c;d;e)
First add a dataset that points to a table(database) made of a numeric progressive field (id) like this: (remember to load the table with a number of rows >= to the possibile number of values in your multi-value-parameter ... or simply load like 10000 rows and i think you'll be ok)
then in the report add a table with: the field id (from Dataset1) and the following expression (representing your parameter P) :
=Parameters!P.Value(Fields!id.Value)
now if you run the report you'll get something like this:
To remove the #Error rows simply filter the entire table like below, and you are done!
来源:https://stackoverflow.com/questions/41953592/ssrs-multivalue-parameter-to-multi-row-table