我应该在月份月变化报告中使用哪些表达式? (SSRS)

时间:2016-06-23 13:47:04

标签: sql-server reporting-services ssrs-2012

我的报告设置如下。我正在使用每月的行组(我打算在最终草案中隐形)来比较本月的第一个月和上个月的第一个,依此类推。

enter image description here

当我运行它时,它看起来像这样

enter image description here

哪个是完美的。然而我需要的是在每天填写空白行,底行减去顶行,以便每月更改一次,我不知道如何实现,或者甚至可能。我假设它是否可能通过使用表达式而不是本报告中的简单表达式

例如,电话回答%=字段!Calls_Answered.Value / Fields!Calls_Offered.Value

我有点超出了我的深度。

这可能是一个最好在SQL级别而不是SSRS级别解决的问题。如果它有用我使用的SQL查询就是这个。

SELECT
CONVERT(DATE,FORMAT([Start Time],'dd/MM/yyyy'),103) AS [Date]
,[Client Name]
,[Account]
,SUM(IIF([Type] in ('Normal operator call','Caller rang off','Caller  rang off during divert','No suitable operator logged on'),1,0)) AS [Calls Offered]
,SUM(IIF([Type] in ('Normal operator call'),1,0)) AS [Calls Answered]
,SUM(IIF([Type] in ('Caller rang off','Caller rang off during  divert','No suitable operator logged on'),1,0)) AS [Ring Offs]
,SUM(IIF([Ring (secs)] <= 20 AND [Type] in ('Normal operator  call'),1,0)) AS [Answered in 20 Secs]
,SUM(IIF([Ring (secs)] > 5 AND [Type] in ('Caller rang off','Caller  rang off during divert','No suitable operator logged on'),1,0)) AS [CRO After 5 Secs]
,AVG(IIF([Type] in ('Normal operator call'),[Ring (secs)],null)) AS 'Avg Time to Answer'
,AVG(IIF([Type] in ('Normal operator call'),[Connected (secs)],null))  AS 'Avg Call Time'
FROM InboundCallsView    
WHERE [Client Name] = (@Client) and [Start Time] >= DATEADD(m,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()), 0))    
GROUP BY FORMAT([Start Time],'dd/MM/yyyy'),[client name],[account]    
ORDER BY [Client Name],[date]

1 个答案:

答案 0 :(得分:1)

您可以使用SUM()函数执行IIF(),如果它符合将其置于顶行的条件,则将该度量乘以* -1

在伪代码中,使用[Calls Answered]作为示例,它看起来像这样:

SUM(IIF({This is the top row}, -1 * [Calls Answered], [Calls Answered]))

我不知道您报告的所有可能参数,所以我不知道具体如何确定一行是否会排在最前面。您的样本结果的一种方法是检查DATEDIFF在几个月内([Date]和GETDATE()之间)是否为零。