SSRS 自定义排序一列 ASC 和 DESC
SSRS custom sort one column ASC and DESC
使用附加数据集生成 SSRS 报告。
我一直在尝试按升序和降序对以下列进行排序。 Sales_Status 列按升序排序,而 Serial_Number 数字列需要按如下方式排序。
Serial_Number 列的父组为 Sales_Status 列
当 Sales_Status 列是“期货销售”时,我想 Serial_Number 升序排列,当“过去的销售”时,它应该降序排列。我尝试了不同的排序顺序但没有运气。找到附加的预期结果
使用了 Tsql 查询
DECLARE @SalesTBL TABLE (Department VARCHAR(10), Sales_Status VARCHAR(50), Serial_Number INT);
INSERT INTO @SalesTBL VALUES
('A','Past Sales','3'),('D','Futures Sales','1'),('H','Futures Sales','1'),('L','Past Sales','3'),
('H','Past Sales','5'),('D','Past Sales','1'),('L','Past Sales','2'),('B','Futures Sales','6'),
('P','Past Sales','5'),('A','Past Sales','4'),('Q','Past Sales','1'),('D','Past Sales','6'),
('D','Past Sales','6'),('O','Past Sales','4'),('I','Past Sales','5'),('Q','Past Sales','4'),
('F','Past Sales','2'),('N','Past Sales','5'),('H','Past Sales','1'),('H','Past Sales','3'),
('P','Past Sales','3'),('H','Past Sales','4'),('B','Past Sales','4'),('L','Past Sales','5'),
('H','Past Sales','5'),('Q','Past Sales','5'),('H','Past Sales','4'),('D','Past Sales','2'),
('k','Past Sales','2'),('H','Past Sales','3'),('E','Past Sales','2'),('F','Past Sales','2'),
('D','Past Sales','3'),('R','Past Sales','4'),('D','Past Sales','3'),('L','Past Sales','2'),
('M','Futures Sales','6'),('I','Futures Sales','3'),('D','Past Sales','1'),('A','Futures Sales','1'),
('E','Futures Sales','3'),('A','Past Sales','5'),('L','Past Sales','6'),('F','Past Sales','3'),
('O','Past Sales','4'),('H','Past Sales','4'),('D','Past Sales','3'),('F','Past Sales','1'),
('A','Past Sales','6'),('U','Past Sales','6'),('H','Past Sales','2'),('F','Past Sales','4'),
('R','Past Sales','6'),('O','Past Sales','5'),('E','Past Sales','1'),('H','Past Sales','6'),
('B','Past Sales','4'),('H','Past Sales','6'),('H','Past Sales','5'),('N','Past Sales','1'),
('O','Past Sales','6'),('Q','Past Sales','2'),('A','Past Sales','5'),('I','Past Sales','4'),
('H','Past Sales','5'),('L','Futures Sales','6'),('k','Past Sales','1'),('H','Past Sales','4'),
('N','Futures Sales','4'),('k','Past Sales','4'),('O','Past Sales','2'),('F','Past Sales','4'),
('Q','Past Sales','4'),('A','Past Sales','1'),('L','Past Sales','4'),('A','Past Sales','3'),
('F','Past Sales','3'),('K','Past Sales','2'),('H','Past Sales','5'),('B','Past Sales','4'),
('O','Past Sales','1'),('O','Past Sales','1'),('H','Past Sales','6'),('F','Past Sales','4'),
('k','Past Sales','1'),('T','Past Sales','6'),('D','Past Sales','4'),('R','Past Sales','4'),
('B','Past Sales','6'),('H','Past Sales','4'),('A','Past Sales','2'),('B','Past Sales','2'),
('H','Past Sales','2'),('H','Past Sales','3'),('F','Past Sales','1'),('F','Futures Sales','3'),
('H','Past Sales','1'),('H','Futures Sales','6'),('H','Past Sales','5'),('N','Past Sales','2'),
('R','Futures Sales','3'),('H','Past Sales','2'),('E','Futures Sales','5'),
('F','Past Sales','5'),('D','Past Sales','4'),('H','Past Sales','6'),('H','Futures Sales','2'),
('B','Past Sales','6'),('K','Past Sales','1'),('N','Past Sales','2'),('D','Past Sales','2'),
('W','Past Sales','2'),('S','Futures Sales','2'),('H','Past Sales','1'),('E','Past Sales','6'),
('E','Past Sales','5'),('N','Past Sales','6'),('k','Past Sales','5'),('S','Past Sales','1'),
('O','Past Sales','4'),('Q','Past Sales','6'),('F','Past Sales','2'),('O','Past Sales','4'),
('B','Past Sales','5'),('K','Futures Sales','4'),('F','Past Sales','6'),('A','Past Sales','4'),
('N','Past Sales','5'),('B','Past Sales','1'),('S','Past Sales','3'),('H','Past Sales','6'),
('L','Past Sales','6'),('O','Past Sales','5'),('H','Past Sales','6'),('R','Past Sales','4'),
('k','Past Sales','5'),('H','Past Sales','3'),('F','Past Sales','1'),('A','Futures Sales','1'),
('F','Past Sales','4'),('B','Past Sales','5'),('k','Past Sales','4'),('D','Past Sales','5'),
('B','Past Sales','2'),('k','Past Sales','1'),('L','Past Sales','4'),('B','Past Sales','4'),
('I','Past Sales','5'),('H','Past Sales','1'),('K','Past Sales','3'),('E','Past Sales','4'),
('E','Past Sales','1'),('A','Past Sales','6'),('A','Past Sales','4'),('k','Past Sales','6'),
('A','Past Sales','3'),('A','Past Sales','2'),('H','Futures Sales','4'),
('W','Past Sales','3'),('Q','Past Sales','1'),('k','Past Sales','5'),('S','Past Sales','1'),
('Q','Past Sales','5'),('H','Past Sales','4'),('V','Past Sales','6'),('N','Past Sales','6'),
('H','Past Sales','2'),('k','Past Sales','1'),('H','Past Sales','3'),('K','Futures Sales','1'),
('H','Past Sales','1'),('H','Past Sales','3'),('K','Past Sales','1'),('D','Past Sales','5'),
('B','Past Sales','6'),('N','Past Sales','3'),('B','Past Sales','3'),('O','Past Sales','3'),
('D','Past Sales','5'),('A','Past Sales','5'),('F','Past Sales','4'),('A','Past Sales','4'),
('F','Past Sales','3'),('J','Past Sales','6'),('k','Past Sales','3'),('H','Past Sales','3'),
('E','Past Sales','4'),('A','Past Sales','1'),('H','Past Sales','2'),('F','Past Sales','1'),
('K','Past Sales','5'),('B','Past Sales','2'),('E','Past Sales','4'),('B','Past Sales','6'),
('L','Past Sales','4'),('T','Past Sales','3'),('H','Past Sales','6'),('k','Futures Sales','4'),
('H','Past Sales','1'),('D','Futures Sales','3'),('M','Past Sales','5'),('L','Past Sales','2'),
('O','Past Sales','2'),('B','Past Sales','1'),('k','Past Sales','1'),('F','Past Sales','2'),
('E','Past Sales','1'),('N','Past Sales','5'),('B','Past Sales','5'),('H','Past Sales','2'),
('F','Past Sales','6'),('k','Past Sales','2'),('M','Past Sales','1'),('K','Past Sales','1'),
('H','Past Sales','4'),('N','Past Sales','4'),('M','Past Sales','1'),('H','Past Sales','2'),
('D','Futures Sales','6'),('F','Past Sales','2'),('S','Past Sales','3'),
('T','Past Sales','1'),('N','Past Sales','3'),('D','Past Sales','3'),('O','Past Sales','2'),
('P','Past Sales','6'),('k','Past Sales','3'),('L','Past Sales','6'),('H','Past Sales','6'),
('F','Past Sales','3'),('A','Past Sales','6'),('k','Past Sales','4'),('Q','Past Sales','1'),
('Q','Futures Sales','4'),('Q','Past Sales','5'),('O','Past Sales','5'),
('T','Past Sales','2'),('L','Past Sales','5'),('B','Past Sales','6'),('L','Past Sales','4'),
('S','Past Sales','4'),('K','Futures Sales','2'),('D','Past Sales','6'),('O','Past Sales','3'),
('B','Past Sales','6'),('H','Past Sales','4'),('H','Past Sales','2'),('F','Past Sales','2'),
('A','Past Sales','4'),('B','Past Sales','6'),('F','Past Sales','4'),('K','Past Sales','1'),
('A','Past Sales','6'),('L','Past Sales','5'),('O','Past Sales','4'),('B','Futures Sales','5'),
('S','Past Sales','5'),('B','Futures Sales','2'),('k','Past Sales','5'),('A','Past Sales','6'),
('k','Past Sales','3'),('H','Past Sales','3'),('Q','Past Sales','1'),('H','Past Sales','3'),
('T','Past Sales','6'),('R','Past Sales','6'),('B','Past Sales','5'),('U','Past Sales','5'),
('K','Past Sales','2'),('B','Futures Sales','2'),('B','Past Sales','3'),('F','Past Sales','5'),
('L','Past Sales','5'),('k','Past Sales','3'),('O','Past Sales','6'),('H','Past Sales','2'),
('L','Past Sales','5'),('T','Past Sales','6'),('E','Past Sales','3'),
('L','Past Sales','2'),('B','Futures Sales','5'),('F','Past Sales','2'),('D','Past Sales','3'),
('N','Past Sales','3');
SELECT * FROM @SalesTBL
输出
在序列号组中您将设置两个排序表达式:
上升
=Iif(Fields!Sales_Status.Value="Past Sales", Fields!Serial_Number.Value,"")
下降
=Iif(Fields!Sales_Status.Value="Future Sales", Fields!Serial_Number.Value,"")
使用附加数据集生成 SSRS 报告。 我一直在尝试按升序和降序对以下列进行排序。 Sales_Status 列按升序排序,而 Serial_Number 数字列需要按如下方式排序。 Serial_Number 列的父组为 Sales_Status 列 当 Sales_Status 列是“期货销售”时,我想 Serial_Number 升序排列,当“过去的销售”时,它应该降序排列。我尝试了不同的排序顺序但没有运气。找到附加的预期结果
使用了 Tsql 查询
DECLARE @SalesTBL TABLE (Department VARCHAR(10), Sales_Status VARCHAR(50), Serial_Number INT);
INSERT INTO @SalesTBL VALUES
('A','Past Sales','3'),('D','Futures Sales','1'),('H','Futures Sales','1'),('L','Past Sales','3'),
('H','Past Sales','5'),('D','Past Sales','1'),('L','Past Sales','2'),('B','Futures Sales','6'),
('P','Past Sales','5'),('A','Past Sales','4'),('Q','Past Sales','1'),('D','Past Sales','6'),
('D','Past Sales','6'),('O','Past Sales','4'),('I','Past Sales','5'),('Q','Past Sales','4'),
('F','Past Sales','2'),('N','Past Sales','5'),('H','Past Sales','1'),('H','Past Sales','3'),
('P','Past Sales','3'),('H','Past Sales','4'),('B','Past Sales','4'),('L','Past Sales','5'),
('H','Past Sales','5'),('Q','Past Sales','5'),('H','Past Sales','4'),('D','Past Sales','2'),
('k','Past Sales','2'),('H','Past Sales','3'),('E','Past Sales','2'),('F','Past Sales','2'),
('D','Past Sales','3'),('R','Past Sales','4'),('D','Past Sales','3'),('L','Past Sales','2'),
('M','Futures Sales','6'),('I','Futures Sales','3'),('D','Past Sales','1'),('A','Futures Sales','1'),
('E','Futures Sales','3'),('A','Past Sales','5'),('L','Past Sales','6'),('F','Past Sales','3'),
('O','Past Sales','4'),('H','Past Sales','4'),('D','Past Sales','3'),('F','Past Sales','1'),
('A','Past Sales','6'),('U','Past Sales','6'),('H','Past Sales','2'),('F','Past Sales','4'),
('R','Past Sales','6'),('O','Past Sales','5'),('E','Past Sales','1'),('H','Past Sales','6'),
('B','Past Sales','4'),('H','Past Sales','6'),('H','Past Sales','5'),('N','Past Sales','1'),
('O','Past Sales','6'),('Q','Past Sales','2'),('A','Past Sales','5'),('I','Past Sales','4'),
('H','Past Sales','5'),('L','Futures Sales','6'),('k','Past Sales','1'),('H','Past Sales','4'),
('N','Futures Sales','4'),('k','Past Sales','4'),('O','Past Sales','2'),('F','Past Sales','4'),
('Q','Past Sales','4'),('A','Past Sales','1'),('L','Past Sales','4'),('A','Past Sales','3'),
('F','Past Sales','3'),('K','Past Sales','2'),('H','Past Sales','5'),('B','Past Sales','4'),
('O','Past Sales','1'),('O','Past Sales','1'),('H','Past Sales','6'),('F','Past Sales','4'),
('k','Past Sales','1'),('T','Past Sales','6'),('D','Past Sales','4'),('R','Past Sales','4'),
('B','Past Sales','6'),('H','Past Sales','4'),('A','Past Sales','2'),('B','Past Sales','2'),
('H','Past Sales','2'),('H','Past Sales','3'),('F','Past Sales','1'),('F','Futures Sales','3'),
('H','Past Sales','1'),('H','Futures Sales','6'),('H','Past Sales','5'),('N','Past Sales','2'),
('R','Futures Sales','3'),('H','Past Sales','2'),('E','Futures Sales','5'),
('F','Past Sales','5'),('D','Past Sales','4'),('H','Past Sales','6'),('H','Futures Sales','2'),
('B','Past Sales','6'),('K','Past Sales','1'),('N','Past Sales','2'),('D','Past Sales','2'),
('W','Past Sales','2'),('S','Futures Sales','2'),('H','Past Sales','1'),('E','Past Sales','6'),
('E','Past Sales','5'),('N','Past Sales','6'),('k','Past Sales','5'),('S','Past Sales','1'),
('O','Past Sales','4'),('Q','Past Sales','6'),('F','Past Sales','2'),('O','Past Sales','4'),
('B','Past Sales','5'),('K','Futures Sales','4'),('F','Past Sales','6'),('A','Past Sales','4'),
('N','Past Sales','5'),('B','Past Sales','1'),('S','Past Sales','3'),('H','Past Sales','6'),
('L','Past Sales','6'),('O','Past Sales','5'),('H','Past Sales','6'),('R','Past Sales','4'),
('k','Past Sales','5'),('H','Past Sales','3'),('F','Past Sales','1'),('A','Futures Sales','1'),
('F','Past Sales','4'),('B','Past Sales','5'),('k','Past Sales','4'),('D','Past Sales','5'),
('B','Past Sales','2'),('k','Past Sales','1'),('L','Past Sales','4'),('B','Past Sales','4'),
('I','Past Sales','5'),('H','Past Sales','1'),('K','Past Sales','3'),('E','Past Sales','4'),
('E','Past Sales','1'),('A','Past Sales','6'),('A','Past Sales','4'),('k','Past Sales','6'),
('A','Past Sales','3'),('A','Past Sales','2'),('H','Futures Sales','4'),
('W','Past Sales','3'),('Q','Past Sales','1'),('k','Past Sales','5'),('S','Past Sales','1'),
('Q','Past Sales','5'),('H','Past Sales','4'),('V','Past Sales','6'),('N','Past Sales','6'),
('H','Past Sales','2'),('k','Past Sales','1'),('H','Past Sales','3'),('K','Futures Sales','1'),
('H','Past Sales','1'),('H','Past Sales','3'),('K','Past Sales','1'),('D','Past Sales','5'),
('B','Past Sales','6'),('N','Past Sales','3'),('B','Past Sales','3'),('O','Past Sales','3'),
('D','Past Sales','5'),('A','Past Sales','5'),('F','Past Sales','4'),('A','Past Sales','4'),
('F','Past Sales','3'),('J','Past Sales','6'),('k','Past Sales','3'),('H','Past Sales','3'),
('E','Past Sales','4'),('A','Past Sales','1'),('H','Past Sales','2'),('F','Past Sales','1'),
('K','Past Sales','5'),('B','Past Sales','2'),('E','Past Sales','4'),('B','Past Sales','6'),
('L','Past Sales','4'),('T','Past Sales','3'),('H','Past Sales','6'),('k','Futures Sales','4'),
('H','Past Sales','1'),('D','Futures Sales','3'),('M','Past Sales','5'),('L','Past Sales','2'),
('O','Past Sales','2'),('B','Past Sales','1'),('k','Past Sales','1'),('F','Past Sales','2'),
('E','Past Sales','1'),('N','Past Sales','5'),('B','Past Sales','5'),('H','Past Sales','2'),
('F','Past Sales','6'),('k','Past Sales','2'),('M','Past Sales','1'),('K','Past Sales','1'),
('H','Past Sales','4'),('N','Past Sales','4'),('M','Past Sales','1'),('H','Past Sales','2'),
('D','Futures Sales','6'),('F','Past Sales','2'),('S','Past Sales','3'),
('T','Past Sales','1'),('N','Past Sales','3'),('D','Past Sales','3'),('O','Past Sales','2'),
('P','Past Sales','6'),('k','Past Sales','3'),('L','Past Sales','6'),('H','Past Sales','6'),
('F','Past Sales','3'),('A','Past Sales','6'),('k','Past Sales','4'),('Q','Past Sales','1'),
('Q','Futures Sales','4'),('Q','Past Sales','5'),('O','Past Sales','5'),
('T','Past Sales','2'),('L','Past Sales','5'),('B','Past Sales','6'),('L','Past Sales','4'),
('S','Past Sales','4'),('K','Futures Sales','2'),('D','Past Sales','6'),('O','Past Sales','3'),
('B','Past Sales','6'),('H','Past Sales','4'),('H','Past Sales','2'),('F','Past Sales','2'),
('A','Past Sales','4'),('B','Past Sales','6'),('F','Past Sales','4'),('K','Past Sales','1'),
('A','Past Sales','6'),('L','Past Sales','5'),('O','Past Sales','4'),('B','Futures Sales','5'),
('S','Past Sales','5'),('B','Futures Sales','2'),('k','Past Sales','5'),('A','Past Sales','6'),
('k','Past Sales','3'),('H','Past Sales','3'),('Q','Past Sales','1'),('H','Past Sales','3'),
('T','Past Sales','6'),('R','Past Sales','6'),('B','Past Sales','5'),('U','Past Sales','5'),
('K','Past Sales','2'),('B','Futures Sales','2'),('B','Past Sales','3'),('F','Past Sales','5'),
('L','Past Sales','5'),('k','Past Sales','3'),('O','Past Sales','6'),('H','Past Sales','2'),
('L','Past Sales','5'),('T','Past Sales','6'),('E','Past Sales','3'),
('L','Past Sales','2'),('B','Futures Sales','5'),('F','Past Sales','2'),('D','Past Sales','3'),
('N','Past Sales','3');
SELECT * FROM @SalesTBL
输出
在序列号组中您将设置两个排序表达式:
上升
=Iif(Fields!Sales_Status.Value="Past Sales", Fields!Serial_Number.Value,"")
下降
=Iif(Fields!Sales_Status.Value="Future Sales", Fields!Serial_Number.Value,"")