I am having an issue and I'm not sure how to solve it.
I have an SSRS report that pulls from a table. I want a parameter filter to show de-duplicated values based on available options in one of the columns.
So my dataset with a query like:
SELECT * FROM table1 WITH (NOLOCK) WHERE col1 IN (@param)
Then I want a parameter called param
that gets its available and default values from col1
in the above data set and I want them to be de-duplicated.
From reading online I learned I have to create a dummy param and use VBA code to de-duplicate that list.
So I have these params:
param_dummy
that gets its available and default values from col1
in the above dataset param
that gets a de-duplicate list from param_dummy
using Code.RemoveDuplicates
But I'm having an issue with circular logic. param
gets its value from param_default
which gets its value from the dataset/query which uses param
.
How can I solve this?
One thought is to remove the WHERE col1 IN (@param)
and instead use a filter on the Tablix table in the SSRS report. This works but I am wondering how efficient it is.
And/or if anyone has any other suggestions I am all ears.
So let us say I have a table in my DB like so:
| id | col1 | col2 |
|----|------|--------|
| 1 | a | hello |
| 2 | b | how |
| 3 | a | are |
| 4 | c | you |
| 5 | d | on |
| 6 | a | this |
| 7 | b | lovely |
| 8 | c | day |
What I want is:
col1
(de-duplicated)col2
So I have a dataset with a query like so:
SELECT
*
FROM dbo.table1
WHERE col1 IN (@col1options) AND (@col2value IS NULL OR col2 = @col2value)
Then for col1options
I would make available and default options be Get values from a query
and I would use the above dataset and col1
.
But this won't work since the query/dataset depends on col1options
which gets its default values from the query/dataset.
I can use a second dataset but that means making multiple calls to the SQL server and I want to avoid that.
I'm not sure I understand your issue so this is a guess...
If you mean you want to be able to filter your data by choosing one or more entries from a specific column in the table, but this column has duplicates and you want your parameter list to not show duplicates then this is what do to.
dsMain
as SELECT * FROM myTable WHERE myColumn IN (@myParam)
dsParamValues
as SELECT DISTINCT myColumn FROM myTable ORDER BY myColumn
dsParamValues
dsMain
Found an easier solution.
It should work as expected at that point! You should be able to select one, some or all parameters and your report should update accordingly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.