[英]Using two datasets in a single report using SQL server reporting service
I need to show a report of same set of data with different condition. 我需要显示具有不同条件的同一组数据的报告。
so that my result will be as follwsinitialy it will be like 这样我的结果就会像下面这样
Region - Country - New Reg - Total Reg - User Type 1 - UserType2
+ Region1 2 10 1 5 1 5
+ Region2 3 7 2 4 1 3
and upon expanding the region it will be like 在扩大区域时,它将像
Region - Country - New Reg - Total Reg - User Type 1 - UserType2
+ Region1 2 10 1 5 1 5
country1 1 2 1 2 - -
country2 1 8 1 8 - -
+ Region2 3 7 2 4 1 3
Is there a way I can show my report like this, I have tried with two data sets one with conditional datas and other with non conditional but it didn't work, its always bing total number of regiostered users for all the total reg columns 有没有办法像这样显示我的报告,我尝试了两个数据集,一个带有条件数据,另一个带有非条件数据,但是它不起作用,它总是对所有reg字段的注册用户总数
Unless I'm mistaken, you're trying to create an expandable table, with different grouping levels? 除非我弄错了,否则您正在尝试创建具有不同分组级别的可扩展表? Fortunately, this can be easily done in SSRS if you know where to look.
幸运的是,如果您知道要查找的位置,则可以在SSRS中轻松完成此操作。 The totals on your example don't seem to match up in the user columns, so I may have misunderstood the problem.
您的示例中的总数似乎在用户列中不匹配,因此我可能误解了这个问题。
For starters, set up your query to produce a single dataset like this: 首先,请设置查询以生成单个数据集,如下所示:
Region Country New Reg - Total Reg - User Type 1 - User Type 2
Region1 country1 1 2 1
Region1 country2 1 8 1
Region2 country3 2 4 1 1
Region2 country4 1 3 1
Now that you've got that, you want to set up a new table with the fields "NewReg", "TotalReg", "UserType1" and "UserType2". 现在,您已经要使用字段“ NewReg”,“ TotalReg”,“ UserType1”和“ UserType2”建立一个新表。 Then right-click the table row, and go to "Add Group > Row Group > Parent Group".
然后右键单击表行,然后转到“添加组>行组>父组”。 Select "Country" in the Group by and click okay.
在分组依据中选择“国家”,然后单击“确定”。 Then, repeat this process and select "Region".
然后,重复此过程并选择“区域”。 This time however, tick the "Add group header" box.
但是,这次,选中“添加组标题”框。 This will insert another row above the original.
这将在原始文件上方插入另一行。
Now, for each of your fields ("NewReg", "TotalReg" etc), click in the new row above and select the field again. 现在,对于您的每个字段(“ NewReg”,“ TotalReg”等),单击上方的新行,然后再次选择该字段。 this will automaticaly add a Sum(FieldName) value into the cell.
这将自动将Sum(FieldName)值添加到单元格中。 This will add together all the individual row totals and present a new, grouped by region row when you run the report.
这将在运行报告时将所有单独的行总计加在一起,并显示一个新的按区域行分组的行。
That should give you the table you require with the data aggregated correctly, so all you need to do is manage the show/hide the detail rows on demand. 这样可以为您提供所需的表,并正确汇总数据,因此您所需要做的就是管理按需显示/隐藏明细行。
To do this, select your detail row (the original row) and right-click "> Row visibility". 为此,请选择详细信息行(原始行),然后右键单击“>“行可见性””。 Set this to "Hide".
将此设置为“隐藏”。 Now, select the cell that contains the "Region" and take note of its ID using Properties (for now, let's assume it's called "Region").
现在,选择包含“ Region”的单元格,并使用“ Properties”记下它的ID(现在,假设它被称为“ Region”)。 Click back onto your detail row and look at the properties window.
单击返回到详细信息行,然后查看属性窗口。 At the bottom you'll see a "Visibility" setting.
在底部,您将看到“可见性”设置。 In there, set "InitialToggleState" to False and "ToggleItem" to the name of your region group's cell (ie "Region").
在此处,将“ InitialToggleState”设置为False,将“ ToggleItem”设置为您的区域组单元的名称(即“ Region”)。
Now all that should be left is to do the formatting etc and tidy up. 现在剩下要做的就是进行格式化等工作并整理一下。
我已经通过从数据库获取所有记录并过滤记录以使用以下表达式收集新的注册表计数来解决此问题
=Sum(IIF(Fields!RegisteredOn.Value >Parameters!FromDate.Value and Fields!RegisteredOn.Value < Parameters!EndDate.Value , 1,0))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.