SSRS Filter in table

s imam 21 Reputation points
2021-06-15T20:00:57.967+00:00

My data source have multiple years. I want to show latest year of data in one of the table in SSRS report.

When I tried to filter the table with First(field!year.value,"DataSource")

I am getting error message "Aggregate functions cannot be used in dataset filters or data region filters"

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,911 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Joyzhao-MSFT 15,576 Reputation points
    2021-06-16T02:17:46.877+00:00

    Hi @s imam
    Why not query the usage details of the data source in the database?
    1) The way I can think of is to query the creation and modification of the data source through TSQL:

    USE [ReportServer]  
    GO  
      
    SELECT CATALOG.NAME  
        ,CATALOG.[Path]  
        ,DataSource.NAME datasource  
        ,CATALOG.[Description]  
        ,Created.UserName AS CreatedByUser  
        ,CATALOG.[CreationDate]  
        ,Modified.UserName AS ModifiedByUser  
        ,CATALOG.[ModifiedDate]  
    FROM [dbo].[Catalog]  
    LEFT JOIN (  
        SELECT [UserID]  
            ,[UserName]  
        FROM [dbo].[Users]  
        ) AS Created ON CATALOG.CreatedByID = Created.UserID  
    LEFT JOIN (  
        SELECT [UserID]  
            ,[UserName]  
        FROM [dbo].[Users]  
        ) AS Modified ON CATALOG.ModifiedByID = Modified.UserID  
    JOIN DataSource ON CATALOG.ItemID = DataSource.ItemID  
    JOIN CATALOG cat1 ON DataSource.Link = cat1.ItemID  
    WHERE CATALOG.[Type] = 2   
    ORDER BY [Path]  
        ,NAME  
    

    2.)Select the data source within one year by setting parameters in SSRS:
    I am not sure whether I can directly filter out the data sources within a year in SSMS, because I am not good at using TSQL.

    Hope this helps. If I misunderstand what you mean,please feel free to correct me.
    Best Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. VJ-5333 1 Reputation point
    2021-06-18T15:01:02.553+00:00

    Hello,

    If you are looking for filtering at tablix label only then you can put filter column grouping of your Year Column. Refer the below URL for Reference:

    http://www.sqlcircuit.com/2013/09/ssrs-how-to-filter-report-data-at.html

    Thanks,
    VJ

    ****f the answer is helpful, please click "Accept Answer" and upvote it****

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.