简体   繁体   中英

How to filter the records in SSRS report

I have been working in SSRS report where I need to show the records of the online users and the type of department they are logged in.

the data I have in the DB are like this.

Data         Type                 UserName   
10/02/2014   Login                Admin
10/02/2014   OperationsLoggedIn   Admin
10/02/2014   Logout               Admin
10/02/2014   Login                User
10/03/2014   OperationsLoggedIn   User
10/03/2014   FinanceloggedIn      ABC

Now I need to show in the SSRS report in the table. I just want to show the which are the users that are online and also need to check that the users listed shouldn't have logged out.

In this case I need to show 2 entry only.

10/03/2014   OperationsLoggedIn   User
10/03/2014   FinanceloggedIn      ABC

The reason I don't want to show the admin entry is because he has already logged out. So how should I apply filtering in SSRS ?

The condition I want to check is :

1. Only OperationsLogedIn and FinaceLoggedIn should show
2. User should not have logged out.

Can anyone guide me for this ?

I believe the first column [Data] must have DateTime so that we can identify the last/latest activity or Type of a particular user like Admin login @10AM & logout @11AM... Doing this way we need to get latest activity of user and then condition of whatever you want to include or exclude in SSRS Report

SELECT * FROM
(Select Data,Type,UserName,Rank() Over(Partition By UserName Order By Data Desc) AS ActiveStatus
    From Table1
) LoginDetails Where ActiveStatus=1 --(To get current status of user)   

If you right click on your dataset and click 'Dataset Properties...', under the 'Filters' tab is where you can apply filters, if you don't want to add them through your SQL. If there are other columns that tell you whether a user is logged in or not, you can simply tack on more filters. Ex:

Expression: [Type] Operator: In Value: OperationsLogedIn, FinaceLoggedIn

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