我正在尝试根据表格记录填充颜色。
从 SQL Server AdventureWorks2017 数据库:
select * from [HumanResources].[Department]
我有两个数据集:
1st : select * from [HumanResources].[Department]
DepartmentID Name GroupName Status
----------------------------------------------------------------------------------------------------------------------------------------
1 Engineering Research and Development Cancelled
2 Tool Design Research and Development Blacklist
3 Sales Sales and Marketing Approved
4 Marketing Sales and Marketing All good
5 Purchasing Inventory Management xxx
6 Research and Development Research and Development yyy
7 Production Manufacturing zzz
8 Production Control Manufacturing xxx
9 Human Resources Executive General and Administration zzz
10 Finance Executive General and Administration aaa
11 Information Services Executive General and Administration xxx
12 Document Control Quality Assurance yyy
13 Quality Assurance Quality Assurance zzz
14 Facilities and Maintenance Executive General and Administration aaa
15 Shipping and Receiving Inventory Management bbb
16 Executive Executive General and Administration aaa
第二,我需要获取如下数据并显示在 SSRS 报告中:
Name0 Name1 Name2 Name3 Name4
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Document Control Facilities and Maintenance Information Services Production Control Research and Development
Engineering Finance Marketing Purchasing Sales
Executive Human Resources Production Quality Assurance Shipping and Receiving
NULL NULL NULL NULL Tool Design
我正在使用以下查询获取上述数据:
WITH Table1 AS
(
SELECT [Name]
FROM [HumanResources].[Department]
), CTE AS
(
SELECT [Name], COL, ROW_NUMBER() OVER(PARTITION BY Col ORDER BY [Name]) AS Row
FROM ( SELECT [Name],
5 - NTILE(5) OVER(ORDER BY [Name] DESC) AS Col
FROM Table1
) c
)
SELECT [0], [1], [2], [3], [4]
FROM CTE
PIVOT (MAX([Name]) FOR Col IN ([0], [1], [2], [3], [4])) AS Pvt
ORDER BY Row;
另外,除了上述要求之外,另一个要求是根据“GroupName”和“Status”(即“另一个数据集”的值)填充第二个结果集中的颜色;我正在使用:
select * from [HumanResources].[Department]
我正在尝试以下表达式,以填充第二个数据集的颜色:
=IIF(LOOKUP((Fields!ID0.Value or Fields!ID1.Value or Fields!ID2.Value or Fields!ID3.Value or Fields!ID4.Value),Fields!Name.Value,Fields!GroupName.Value="Research and Development","DsetAll"),"GREEN","WHITE")
=IIF(LOOKUP((Fields!ID0.Value or Fields!ID1.Value or Fields!ID2.Value or Fields!ID3.Value or Fields!ID4.Value),Fields!Name.Value,Fields!GroupName.Value,"DsetAll")="Research and Development","GREEN","WHITE")
问题是上述表达式都不能正常工作。
编辑: 下面的表达式看起来很好用:
=IIF(LOOKUP(Fields!ID0.Value ,Fields!Name.Value,Fields!GroupName.Value,"DsetAll")="Research and Development","BLUE","RED")
看起来,“查找”中的“或”不起作用。我怎样才能使这项工作?还有其他方法吗?
在第二个结果集中,想法是:
if groupname "Research and Development" and status is "Cancelled" then "Green"
if groupname "Research and Development" and status is "Blacklist" then "Green"
if groupname "Sales and Marketing" and status is "Approved" then "Green"
if status is "All good" then Gray
if groupname "Manufacturing" then Blue
if groupname "Control Manufacturing" then red
if groupname "Executive General and Administration" then pink
if groupname "Quality Assurance" then Violet
Else its should be white
第一个表达式没有显示任何填充颜色。此外,NULL/Blank 不应有任何颜色。
第二个表达式有错误:
The Error occurred during local report processing.
The definition of the report '/ColorTest' is invalid.
The BackgroundColor expression for the text box 'ID0' contains an error: [BC30201] Expression expected.
我怎样才能做到这一点?或者,请让我知道是否有其他方法可以实现相同的目标?谢谢