我在SSRS的报告中有一张图表来显示票证数量。有3组:提交,关闭 - FCR,开放。每个组都有4种票据类型:已提交,已关闭,FCR,打开。对于“已提交”和“打开”组,我希望图表上的标签在条形图上居中。当计数为0时,不显示类型。这就是图表现在的样子:
这是我添加到故障单类型系列组的SWITCH
语句,用于对类型进行排序:
=Switch(
Fields!TicketGroup.Value = "Submitted" AND Fields!TicketType.Value = "Submitted", 1,
Fields!TicketGroup.Value = "Submitted" AND Fields!TicketType.Value = "Closed", 2,
Fields!TicketGroup.Value = "Submitted" AND Fields!TicketType.Value = "Open", 3,
Fields!TicketGroup.Value = "Submitted" AND Fields!TicketType.Value = "FCR", 4,
Fields!TicketGroup.Value = "Closed" AND Fields!TicketType.Value = "Open", 1,
Fields!TicketGroup.Value = "Closed" AND Fields!TicketType.Value = "Closed", 2,
Fields!TicketGroup.Value = "Closed" AND Fields!TicketType.Value = "FCR", 3,
Fields!TicketGroup.Value = "Closed" AND Fields!TicketType.Value = "Submitted", 4,
Fields!TicketGroup.Value = "Open" AND Fields!TicketType.Value = "Submitted", 1,
Fields!TicketGroup.Value = "Open" AND Fields!TicketType.Value = "Closed", 2,
Fields!TicketGroup.Value = "Open" AND Fields!TicketType.Value = "Open", 3,
Fields!TicketGroup.Value = "Open" AND Fields!TicketType.Value = "FCR", 4)
关闭 - FCR对中是正确的。需要更正已提交和开放的中心
我的语法在switch
语句中是错误的吗?我不明白为什么它没有居中
更新 添加列以在每个组中排序仍然不起作用。订单使用第一组进行排序。此外,我尝试为每种故障单类型使用相同的值。因此,“已提交”,“已关闭”和“已打开”设置为2,而FCR为3,但这也不起作用。这些值标识为Submitted = 3,Closed = 1,FCR = 4,Open = 2.
更新 我试图使用查找函数来连接列以获得每个组的正确排序顺序。它仍然无法正常工作。 提交的是,Closed = 2,FCR = 3,Open = 4。 排序值必须不同吗?它们不能在不同的组中具有相同的排序值吗?
更新 有没有办法改变x轴标签的距离?
答案 0 :(得分:0)
我已经整理了一张图表,它似乎有用,假设我已经正确地理解了你!
我使用以下查询构建了一个虚拟数据集
declare @data table(TicketGroup varchar(20), TicketType varchar(20), Amount int)
insert into @data
VALUES
('Submitted', 'Submitted', 10),
('Submitted', 'Submitted', 11),
('Submitted', 'Closed', 9),
('Submitted', 'Closed', 12),
('Submitted', 'Closed', 13),
('Submitted', 'Open', 8),
('Submitted', 'FCR', 14),
('Closed - FCR', 'Open', 7),
('Closed - FCR', 'Open', 6),
('Closed - FCR', 'Closed', 10),
('Closed - FCR', 'Closed', 11),
('Closed - FCR', 'Closed', 12),
('Closed - FCR', 'FCR', 3),
('Closed - FCR', 'Submitted', 8),
('Open', 'Submitted', 4),
('Open', 'Closed', 5),
('Open', 'Open', 6),
('Open', 'Open', 7),
('Open', 'FCR', 9),
('Open', 'FCR', 10)
select *
, CASE
WHEN d.TicketGroup = 'Submitted' THEN 1
WHEN d.TicketGroup = 'Closed - FCR' THEN 3
WHEN d.TicketGroup = 'Open' THEN 3
END AS SortLevel1
, CASE
WHEN d.TicketGroup = 'Submitted' and d.TicketType = 'Submitted' THEN 1
WHEN d.TicketGroup = 'Submitted' and d.TicketType = 'Closed' THEN 2
WHEN d.TicketGroup = 'Submitted' and d.TicketType = 'Open' THEN 3
WHEN d.TicketGroup = 'Submitted' and d.TicketType = 'FCR' THEN 4
WHEN d.TicketGroup = 'Closed - FCR' and d.TicketType = 'Open' THEN 1
WHEN d.TicketGroup = 'Closed - FCR' and d.TicketType = 'Closed' THEN 2
WHEN d.TicketGroup = 'Closed - FCR' and d.TicketType = 'FCR' THEN 3
WHEN d.TicketGroup = 'Closed - FCR' and d.TicketType = 'Submitted' THEN 4
WHEN d.TicketGroup = 'Open' and d.TicketType = 'Submitted' THEN 1
WHEN d.TicketGroup = 'Open' and d.TicketType = 'Closed' THEN 2
WHEN d.TicketGroup = 'Open' and d.TicketType = 'Open' THEN 3
WHEN d.TicketGroup = 'Open' and d.TicketType = 'FCR' THEN 4
END as SortLevel2
from
(SELECT TicketGroup, TicketType, SUM(Amount) as Amount FROM @data GROUP BY TicketGroup, TicketType) d
然后我创建了一个简单的柱形图。这是设计。
然后,对于两个类别组,单击设计器中的下拉列表,然后单击“类别组属性”。
转到“排序”选项卡,将排序分别设置为SortLevel1或SortLevel。
最终输出(需要一些整理!)看起来像这样。