[英]How to sum multiple groups in SSRS?
I need to learn how to use SSRS. 我需要学习如何使用SSRS。 If anyone knows any good tutorials please let me know. 如果有人知道任何好的教程,请告诉我。 I am following the one by Microsoft ( https://msdn.microsoft.com/en-us/library/ms170712.aspx ) and am stuck. 我正在关注Microsoft( https://msdn.microsoft.com/en-us/library/ms170712.aspx )并且卡住了。 I do not have the adventure works database so I am using data that I have. 我没有冒险工作数据库所以我使用的是我拥有的数据。
I have some data that looks like this 我有一些看起来像这样的数据
Name or Salesperson Region State Sales
D'Ausilio, Jaclyn E. West & South Alabama 0 757.595541091103 2017-07-04 12:29:12.660
D'Ausilio, Jaclyn E. West & South Alabama 0 831.028260564931 2017-03-29 12:29:12.660
D'Ausilio, Jaclyn E. Great Lakes & East Connecticut 1 406.830337252288 2017-05-22 12:29:12.660
D'Ausilio, Jaclyn E. Great Lakes & East Connecticut 1 945.753297444545 2017-07-07 12:29:12.660
De Loys, Karen Great Lakes & East Illinois 0 776.159963746314 2017-05-10 12:29:12.660
De Loys, Karen Great Lakes & East Illinois 0 599.717806116604 2017-06-06 12:29:12.660
I want totals by state and salesperson. 我想要州和销售人员的总数。 It looks like it can be done by the Microsoft example (Order Total and Daily Total) but I follow their instructions and it fails for me. 它似乎可以通过Microsoft示例(订单总计和每日总计)来完成,但我按照他们的说明进行操作,但对我来说失败了。 I do not know if certain datasets are needed and mine does not meet the criteria. 我不知道是否需要某些数据集,而且我的数据集不符合标准。 Maybe what I want to do is impossible. 也许我想做的事是不可能的。 Perhaps I am just missing something. 也许我只是遗漏了一些东西。 Maybe if someone can answer some questions I can figure it out. 也许如果有人能回答一些问题,我可以弄清楚。
In one attempt my row groups looks like this 在一次尝试中,我的行组看起来像这样
Name 名称
--StateName --StateName
----Details - - 细节
And the other 和另一个
Name 名称
--StateName --StateName
Details 细节
Which is correct and / or what does that mean? 哪个是正确的和/或这是什么意思? Why is details a group? 为什么细节是一组? I cant find the sense in that. 我无法找到感觉。
The field I'm summing on doesn't exist in the database, as far as I know that shouldn't matter, but you never know. 我总结的字段在数据库中不存在,据我所知,这应该不重要,但你永远不知道。 Here's my query. 这是我的查询。
SELECT [Name], Region, StateName, CASE WHEN Territory = 'CT' OR Territory = 'MA' OR Territory = 'NH' OR Territory = 'VT' OR Territory = 'NY' THEN 1 ELSE 0 END NorthEast, RAND(CONVERT(VARBINARY, NEWID())) * 1000 + 100 AS Sales, DATEADD(d, RAND(CONVERT(VARBINARY, NEWID())) * 366, GETDATE()) AS LastSale
FROM SalesRepresentatives AS SR
INNER JOIN Sales_Regions ON SalesRep = SR.ID
INNER JOIN States ON StateAbbreviation = Territory
ORDER BY [Name], StateName
EDIT: I just found something out. 编辑:我刚发现了一些东西。 When I "Add Total" by right clicking on "Sales" it magically breaks on State for the total. 当我通过右键单击“销售”来“添加总计”时,它会神奇地打破状态。 When I right click on the group StateName (same as state) it only puts one total at the bottom. 当我右键单击组StateName(与状态相同)时,它只在底部放置一个总数。 This makes me think it can only break on one group for totals but I must be wrong about that. 这让我觉得它只能打破一组总数,但我必须对此不以为然。 But if you can't break for totals on a group by clicking on the group then "Add Total" how is it done? 但是如果你不能通过点击组来打破一个组的总数,那么“添加总计”是如何完成的?
Finally got it. 终于明白了。 To add a total you click on the group AFTER the group you want the total for. 要添加总计,请单击要在其组之后的组之后的组。 So if you have: 所以如果你有:
Name
State
Detail
To make a total for State you click on detail. 要为州制作一个总数,请单击详细信息。 For State, you click on Name. 对于State,单击Name。 clicking on the Name group creates a Grand Total. 单击“名称”组可创建“总计”。 WTG Microsoft! WTG微软!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.