SSRS:如何显示组标题中的总数的百分比

问题描述:

我有一份报告,显示客户约会,按客户部门分组,过去3个月的销售代表。在客户部门组头中,我想要显示约会所代表的该部门中客户总数的百分比。SSRS:如何显示组标题中的总数的百分比

例如,我的报告显示约翰史密斯在过去3个月为“防务”部门的客户提供了6次约会。约翰史密斯在“地方政府”部门为客户做了4次任命。

我知道我总共有10名国防客户和20名当地政府客户。我怎样才能显示过去三个月在该行业看到的客户比例?

所以我目前有:

Sales Rep: John Smith (10 appointments) 
    Sector: Defence (2 customers) 
      Customer 1 (4 appointments) 
       Appointment 1 -- Blah 
       Appointment 2 -- Blah 
       Appointment 3 -- Blah 
       Appointment 4 -- Blah 
      Customer 2 (2 appointments) 
       Appointment 1 -- Blah 
       Appointment 2 -- Blah 
    Sector: Local Government (2 customers) 
      Customer 3 (3 appointments) 
       Appointment 1 -- Blah 
       Appointment 2 -- Blah 
       Appointment 3 -- Blah 
      Customer 4 (1 appointment) 
       Appointment 1 -- Blah 

而且我想表明:

Sales Rep: John Smith (10 appointments) 
    Sector: Defence (2 customers - **20% of total Defence customers**) 
      Customer 1 (4 appointments) 
       Appointment 1 -- Blah 
       Appointment 2 -- Blah 
       Appointment 3 -- Blah 
       Appointment 4 -- Blah 
      Customer 2 (2 appointments) 
       Appointment 1 -- Blah 
       Appointment 2 -- Blah 
    Sector: Local Government (2 customers - **10% of Local Government customers**) 
      Customer 3 (3 appointments) 
       Appointment 1 -- Blah 
       Appointment 2 -- Blah 
       Appointment 3 -- Blah 
      Customer 4 (1 appointment) 
       Appointment 1 -- Blah 

我是SSRS小白,所以不知道我怎么能做到这一点。我是否将数据集添加到具有每个客户部门中客户总数的报表中?

如果我这样做了,我目前在客户部门组头中显示的表达式中如何使用总数来表示防御,以计算在该部门中看到的总客户的百分比?

由于数据库限制,我无法在源数据库中创建任何表,视图或存储过程,因此所有工作都必须在报告中完成。

我正在使用SSRS 2005.

非常感谢!

我认为你想要完成的事情可能是通过在当前数据的SQL查询中添加%客户作为列来实现。这取决于你现在有多少数据集。如果你发布你的数据集的SQL,我很乐意提供建议;没有它,我将不得不猜测。这可能足以让你走上正确的道路。

如果你有以上被拉入形式的非规范化的大结果的数据:

SELECT 
    SalesRep 
    , Sector 
    , Customer 
    , Appointment 
    , (SELECT count(*) FROM customers WHERE s.sector = sector) as numCustomerPerSector 
FROM SalesReps sr 
INNER JOIN Sectors s 
    ON ... 
... 
WHERE 1=1 

我敢肯定,这并不是最佳的解决方案,但它会奏效。

+0

感谢鲍勃。我最终想出了一个非常类似于你的解决方案。不优雅,但它的作品。 – ABC123 2010-01-28 10:38:32