简体   繁体   中英

filter tablix without datasource values in ssrs

I have SSRS report and I need to filter a static table that I created inside the report based on parameter. There is no data source to this table and I'm entering the data manually. The tablix contain 3 columns. How can I filter the columns based on parameter? I tried in the expression =@param1 for example but it doesn't work. For now I only manage to filter if the expression is on data source fields.

Do you literally have a table with a number of values in it written directly into the report? If so I don't think you will be able to perform any filtering on it as effectively all you've done it write data into textboxes that are displayed.

I would imagine your best option would be to instead create a new dataset and populate this with your static data, eg

SELECT 'A' AS Letter, 'English' AS Language
UNION
SELECT 'B' AS Letter, 'French' AS Language
UNION
SELECT 'A' AS Letter, 'German' AS Language

To give you a table as follows

Letter |  Language
-------+----------
A      |  English
B      |  French
A      |  German

That you could then filter on Letter = A

So essentially you have a Tablix that has 3 columns pre-populated with information you have manually entered into the text boxes themselves? Since you've already entered that data, I don't believe there is a way to filter that at run time. That data is hard coded in essence. The Filter ability in SSRS is used as a WHERE clause so it restricts what is brought forth into the report from the query.

I would create a data source connection to a dummy database, create a DataSet, and create a query that fills a temporary table will all the information that you've manually entered. Once you create the temporary table and inserted values into it, you can then perform a SELECT with a parameter. Your Tablix will only be populated with information that matches the parameter. Something to the effect of this:

CREATE TABLE #TempTable (
    ID INT
    ,Name VARCHAR(MAX)
    ,Email VARCHAR(MAX)
    )

INSERT INTO #TempTable (
    ID
    ,Name
    ,Email
    )
VALUES (
    1
    ,'Bob'
    ,'bob@email.com'
    )
    ,(
    2
    ,'Frank'
    ,'frank@email.com'
    )
    ,(
    3
    ,'Jim'
    ,'jim@email.com'
    )
SELECT
    *
FROM
    #TempTable
WHERE
    ID = @ID
DROP TABLE #TempTable

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM