2017-04-06 68 views
0

我在SSRS中的報告中顯示圖表以顯示票證計數。共有3組:提交,關閉 - FCR,打開。每組有4種提交,關閉,FCR,打開的票類型。對於已提交和打開的組,我希望圖上的標籤集中在欄上。當計數爲0時,類型不顯示。這是圖表的樣子現在: enter image description here在SSRS中的圖表中居中標註組標記

這是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聲明中錯了嗎?我不明白它爲什麼沒有居中對齊

UPDATE 添加一列以在每個組中排序仍然不起作用。訂單使用第一組進行排序。另外,我嘗試爲每種票類使用相同的值。所以提交,關閉和打開設置爲2,FCR爲3,但這也不起作用。該值被確定爲提交= 3,關= 1,FCR = 4,打開= 2

UPDATE 我試圖使用查找功能來連接柱獲得各組的正確排序順序。它仍然沒有工作。 已提交,已關閉= 2,FCR = 3和開放= 4. 排序值是否必須不同?它們在不同的羣體中可能不是同一種價值嗎?

UPDATE 有沒有辦法改變X軸標籤的距離?

+0

不幸的是,那種只對圖表進行一次 - 你不能擁有它的排序分別爲每個組。也許單獨的圖表拼在一起看起來像一個?如果條上有數字,可以刪除這些線(和軸)。現在的趨勢越少(DimGray代替黑色)。 –

+0

您可以向設置排序順序的數據集添加一個新列,然後按該列排序。基本上將你的switch語句複製到SQL中的一個案例中(假設它來自SQL Server)。 –

+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 

然後我創建了一個簡單的列chart.Here的設計建立了一個虛擬數據集。

enter image description here

然後兩個類別組,點擊下拉菜單在設計下來,然後單擊類別組屬性。

轉到「排序」選項卡,並分別將排序設置爲SortLevel1或SortLevel 2。

enter image description here

的最終輸出(需要一些整理的!)看起來是這樣的。

enter image description here

+0

感謝這個例子。我今天會研究它。這個例子和我想要實現的有一些區別。我不知道這是否重要。在我嘗試調和差異並將其應用於我的示例之後,我會讓你知道它是如何發生的。 –

+0

我認爲這不會起作用。在x軸上,您使用2種排序,但我只能在x軸上有1個組。我只想在X軸上提交,關閉FCR和打開。該小組只有在一組中關閉和FCR。已提交的組只有已提交的項目,而打開的組將只有已打開的項目。 FCR是Closed的一個子集,所以我希望他們在一個組中。 –

+0

現在我所看到的是試圖在x軸間隔中定義和表達,以便第一個文本位於左側,最後一個位於右側。 –