SSRS是否可以将用户输入合并到报告中?

时间:2016-09-06 11:17:42

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

我有一个类似于下面的报告(忽略它看起来很糟糕的早期草案)

report 1

我希望用户能够在他们喜欢的任何日期运行报告(使用参数),然后在总班次列中手动输入一个数字并让报告计算有效班次%(通话时间) /总班次)。这可能吗?如果是这样,任何人都可以引导我完成它吗?

1 个答案:

答案 0 :(得分:1)

我个人只是从SQL查询中计算它。更容易,你应该能够达到相同的结果/

因为我对你的表格或数据没有很好的理解,所以我只是将其建模与工作中的结构类似。

这将是我用于生成报告的查询示例。

Declare @ReportStart date = '2016/08/01'    -- SSRS will automatically pick up parameter and add it
Declare @ReportEnd   date = '2016/09/01'    -- SSRS will automatically pick up parameter and add it
/*  - - - Exclude the Above in the SSRS Report Query - - - */


Select
    Agent
,   Calls_Handled
,   Calls_Outgoing
,   Total_TalkTime
,   avg.Talk_Time
,   Time_Woked

-- You can get Super Lazy here and just calculate it SQL Side 
--Not too sure as i dont have DBMS to test in but the below should work?
,   Cast(SUM((Cast(Total_TalkTime as FLOAT) / CAST(Time_Woked as FLOAT))*100) as Numeric(4,2)) as [%_Active]
FROM
(
SELECT
    Resource_Name as [Agent]

,   SUM( -- Calculate total Incoming Calls Handled
        Case When [Contact_Type] in ('Incoming') THEN 1
    END) as [Calls_Handled]

,   SUM( -- Calculate total outgoing Calls Made
        Case When [Contact_Type] in ('Outgoing') THEN 1
    END) as [Calls_Outgoing]

,   SUM(Talk_Time) as [Total Talk_Time] -- Calculate Total TalkTim
,   AVG(Talk_Time) as [avg.Talk_Time]   -- Calculate Average TalkTime
From
    dbo.tbl_Cisco_Calls
WHERE
    Even_Time between @ReportStart and @reportEnd
GROUP BY
    Agent
) as call
JOIN
(
    Select
        Agent
    ,   DateDiff(minute,Login_Time, Logout_Time) as [Time_Woked]
    FROM
        tbl_Cisco_Event
    WHERE
        Event_Time between @reportStart and @reportEnd
    Group By
        Agent
) as event
on call.Agent = event.Agent

将报告加载到SSRS后,它应自动获取参数@ReportStart和@ReportEnd。然后我会调整他们的类型为日期,以便它们可以用作日历。然后你们都完成了交配。

您还可以在SSRS中进行计算

它会拿起实体所以我可以做到

[Total_TalkTime]/[Time_Worked] 

然后右键单击单元格,我可以选择数字类型为百分比(与Excel关闭内存完全相同)

如前所述,虽然在SQL环境中执行此操作会轻松十倍