过滤当前用户的 SSRS 报告

Filter SSRS report to current user

这似乎是一个常见问题,但我找不到有效的解决方案。

我有一份显示员工假期余额的 SSRS 报告。

I want to make a linked report which will only display information for the current user.

内置字段User!UserID,return是用户的Login,但是这个Login在我们的DW中一般不会用到,所以我无法单独过滤掉。 我们有一个存储过程,可以将该登录名转换为匹配的 UserID,然后我可以根据它过滤报告。

My issue there is that although I have a secondary dataset which returns the current users EmployeeID, that dataset cannot be used in the filter of my primary data set, nor in any parameters.

由于需要识别当前用户,我不知道在 SSMS 中执行此操作的方法,但我一直在尝试使其在 SSRS 中工作

为了阐明链接报告的想法,我计划使用一个布尔值,其中 true/false 指示是显示当前用户的数据还是 return 全部。链接的报告是为了不通过这个小改动复制 RDL

任何帮助将不胜感激,这是我相信我以后会再次遇到的问题

我最终解决了这个问题,多亏了来自 TPhe 的精神上的快速启动..

需要什么:

在我的 TSQL 过程中,我创建了两个新变量。一,一个布尔值,用于切换是否过滤人物。此布尔值在 SuperUser 和 Individual 报告版本之间翻转。第二个是 EmpID 过滤器(以前我们只有一个自由文本名称过滤器)

如果将布尔值设置为仅查看个人,则报告将仅过滤到当前用户,这是我通过我在原始问题中提到的 SP 生成的数据集获得的。

The key is the Boolean parameter. I titled it viewALL; Defaulted to True for superusers. I then created the linked report, and altered parameters so that viewAll was set to False, meaning show only the current user information.

我必须将这些参数添加到 SSRS,以便我可以 Manage ReportServer 上的报告并翻转布尔值,当然 SQL 中需要它们以供我使用其中:

Where ((viewALL = 'False' AND EmployeeID = @CurrentEmployeeID) OR (viewALL = 'True' AND EmployeeName like '%+@EmployeeName+%'))